Jump to content

more than one form in a html page


thankqwerty

Recommended Posts

Hi there, i wanted to make something like the commenting system in youtube, i.e. the users can click "reply" to a specific comment and a comment form pops out. I know how to make the comment form appear and disappear using javascript, but i'm not sure with having so many forms in the same page.

 

my experience is that if u have 2 forms with elements that share the same name then the information would mess up, for example.

 

<--? Form 1  -->
<form action="comment.php" method="post"></br>
Title: <input type="text" name="title" size="50"/></br>
Comment: </br>
<TEXTAREA type="text" wrap="physical" NAME="content" COLS=150 ROWS=10></TEXTAREA>
</br>
<input type="submit" value="submit">
</form>

..
..
..

<--? Form 2  -->
<form action="comment.php" method="post"></br>
Title: <input type="text" name="title" size="50"/></br>
Comment: </br>
<TEXTAREA type="text" wrap="physical" NAME="content" COLS=150 ROWS=10></TEXTAREA>
</br>
<input type="submit" value="submit">
</form>

 

Since both forms have "title" and "content" and when i submit something using form1, it will turn out to be empty data. This problem goes away if i name the elements in the 2 forms differently, but then it'll require different action page as the $_POST values have different names, even though the structure of data is the same.

 

Is there anyway to get round this???

Link to comment
Share on other sites

u know.. i not build form head like above!!

i just type without any action ^^

<form method="post">

or even i use action.. i will type

<form action="?act=enterMsg" method="post">

 

but in every last before submit i was place hidden value

<input type=hidden name=act value=enterMsg> if this form using GET not POST

anyway.. you problem is interesting..

 

i think.. this problem because you click wrong submit?

 

 

Link to comment
Share on other sites

You can re-use element names in multiple forms on a page. The only elements that are sent are the ones inside the form tag that the submit button is included in.

 

i just type without any action ^^

 

You should add the action to your form tag. It's invalid code if you don't add it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.