...

View Full Version : Multiple forms on 1 HTML page?



martinjsmith
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.

Thanks,

Martin

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

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

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

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

oracleguy
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...

Zvona
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.

brothercake
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 ...

BrainJar
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:

window.frames["frameA'].forms["formA"].submit();
window.frames["frameB'].forms["formB"].submit();
window.frames["frameC'].forms["formC"].submit();
etc.

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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum