Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jul 2002
    Location
    Glasgow, Scotland
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Multiple forms on 1 HTML page?

    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

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    North East England
    Posts
    853
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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>
    [+] Computer/PC issues [+] Silverpaw3D
    ------------------------------------------------
    Never buy a dwarf with learning disabilities...

    ...it's not big, and it's not clever.

  • #3
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    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...
    OracleGuy

  • #4
    Regular Coder
    Join Date
    May 2002
    Location
    Helsinki, Finland
    Posts
    231
    Thanks
    0
    Thanked 1 Time in 1 Post
    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.
    Zvona
    First Aid for
    Web Design

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by Zvona
    Why would you need to have multiple forms in one page?

    ??? Hundreds of possible reasons ...

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Posts
    185
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •