View Full Version : Multiple forms on 1 HTML page?

07-25-2002, 10:09 PM
Is is possible to have multiple forms on one HTML page? On submitting each form should go to a different desination page? If so, do you have to do anything special with the form declarations because I have tried and any submit button only submits the first form on the page and not the second one.



07-25-2002, 10:17 PM
Just give the forms different names...

<form name="form1" method="post" action="page1.php">
<!-----form code-----!>

<form name="form2" method="post" action="page2.php">
<!-----form code-----!>

<form name="form3" method="post" action="page3.php">
<!-----form code-----!>

07-25-2002, 10:51 PM
Or you could make the form one form and have the two submit buttons regular buttons that when clicked on ran a snipplet of JS code that sets the action for the form and submits it.

Just an idea...

07-26-2002, 11:37 AM
I think you're looking an answer that isn't a real solution. Why would you need to have multiple forms in one page?

Could you be more specific with your problem, because now it seems you're doing something, which can't be considered very useful.

07-26-2002, 12:20 PM
Originally posted by Zvona
Why would you need to have multiple forms in one page?

??? Hundreds of possible reasons ...

07-26-2002, 05:25 PM
When you submit a form, it's just like clicking a link. You're sending an HTTP request to some web server. In the case of a link, it's an HTTP GET. With a form, it's either an HTTP GET or an HTTP POST depending on the method you set on the FORM tag.

Either way, your browser expects the server to respond back by sending a file - usually an HTML page. It sends one request at a time and gets one response back because that's how HTTP works and the browser can only display one page in it's window at a time.

Unless you use frames. In that case, you can have multiple windows and each can display a separate page. But it's still one page per window.

So to submit multiple forms, you have to have each in it's own frame. You can then use some JavaScript to submit all of them off of one button click with something like:


Having multiple forms like that would probably be confusing to users, however. But it could be useful if you're just using forms with hidden fields to pass data back and forth in an application.