thankqwerty Posted January 25, 2009 Share Posted January 25, 2009 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??? Quote Link to comment https://forums.phpfreaks.com/topic/142347-more-than-one-form-in-a-html-page/ Share on other sites More sharing options...
thankqwerty Posted January 25, 2009 Author Share Posted January 25, 2009 wait wait, maybe i'm wrong ....... ??? :-\ Quote Link to comment https://forums.phpfreaks.com/topic/142347-more-than-one-form-in-a-html-page/#findComment-745844 Share on other sites More sharing options...
landavia Posted January 25, 2009 Share Posted January 25, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/142347-more-than-one-form-in-a-html-page/#findComment-745866 Share on other sites More sharing options...
haku Posted January 26, 2009 Share Posted January 26, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/142347-more-than-one-form-in-a-html-page/#findComment-746266 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.