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 5 of 5
  1. #1
    New Coder
    Join Date
    Jul 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Multiple form submit using single button

    Hi,

    I need to submit multiple forms with using single button. I've mentioned my code below.

    <?
    if(isset($_POST)){
    print_r($_POST);
    }
    ?>
    <script type="text/javascript">
    function form2Submit() {
    document.f2.action="formsubmit2.php"
    document.f2.submit();
    alert('Form2 Submitted');
    }

    function form1Submit() {
    document.f1.action="formsubmit2.php"
    document.f1.submit();
    document.getElementById("t1").value = '';
    alert('Form1 Submitted');
    }


    function submitAllForm() {
    form1Submit();
    form2Submit();
    }
    </script>
    </HEAD>

    <body>
    <form name="f1" method="post">
    F1 NAME: <input type="text" name="t1" id="t1" size="24" value="txt1" />
    </form>
    <form name="f2" method="post">
    F2 NAME: <input type="text" name="t2" id="t2" size="24" value="txt2" />
    </form>
    <input type="button" value="Submit" onClick="submitAllForm()" />
    </body>

    Its working properly in IE but not in Mozilla. do you have any idea ?

    Thanks.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Is there a compelling reason you are using two forms? Why not just use one form?

  • #3
    New Coder
    Join Date
    Jul 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi buddy,

    Thanx for your reply. Im using two forms with separate tabs. I need to fill two tabs. so with one buttion i've to submit two forms thats why.

  • #4
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    And why can't the two tabs go under the umbrella of a single form? I'm just trying to make your life simple. Usually the only reason for more than one form is because you actually need them to submit separately, so when you use two forms that you need to submit together, it defeats the point of having two forms and just complicates matters.

  • #5
    New Coder
    Join Date
    Nov 2007
    Posts
    72
    Thanks
    0
    Thanked 1 Time in 1 Post
    By 'having them in two tabs' do you mean that, depending on the answer to a particular question, the user either fills out one form or the other? If so, you can use one form and have two submit buttons (one in each tab) with the same name but different values. That way when the page loads, you can just parse the submit variable in PHP, performing one task for value A and another task for value B.

    Hope this helps.


  •  

    Posting Permissions

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