Closed Thread
Results 1 to 4 of 4

Thread: Submit two forms with one button

  1. #1
    rushhh is offline Newbie
    Join Date
    Mar 2009
    Posts
    9
    Rep Power
    0

    Submit two forms with one button

    Hope this the right place to post this question.

    I'm trying to Submit two forms with one button and one by one. Submit one by one is working. But can't finger out how to submit both at the same time.

    Code:
    <script type="text/javascript">
    function f1Submit()  {
    var n1 = document.f1.t1.value;
    var n2 = document.f2.t2.value;
    	if (!n1)  {
    		document.f2.t2.value = n2;
    		document.f2.action="/test2.php"
    		document.f2.submit();
    	}
    	else if (!n2)  {
    	document.f1.t1.value = n1;
    	document.f1.action="/test2.php"
    	document.f1.submit();
    	}
    	else if (n1 && n2){   //Submitting at the same time.
    		alert ("hello");
    	document.f1.t1.value = n1;
    	document.f2.t2.value = n2;
    	document.f1.action="/test2.php"
    	document.f2.action="/test2.php"
    	document.f1.submit();
    	document.f2.submit();
    	
    	}
    }
    function submitAll() {
    f1Submit();
    }                                                          
    </script>
    </HEAD>
    
    <BODY onload="document.f1.t1.focus();">
    <form name="f1" method="get"  enctype="multipart/form-data">
    
    F1 NAME: <input type="text" name="t1"  size="24"  />
    </form>
    
    <form name="f2" method="get"  enctype="multipart/form-data">
     
    F2 NAME: <input type="text" name="t2"  size="24"  />
    </form>
    
    <form name="allSubmit">
    <input type="button"  name="btn1"  value="Submit"  onClick="submitAll()" />
    </form>
    Thanks

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Jordan Guest

    Re: Submit two forms with one button

    You'll have to use AJAX to submit two forms at once. When you try to submit two forms without it, the browser will want to go to the ACTION url specified in the form. You could submit one via AJAX and proceed with the second one regularly.

  4. #3
    rushhh is offline Newbie
    Join Date
    Mar 2009
    Posts
    9
    Rep Power
    0

    Re: Submit two forms with one button

    ok thanks, maybe it best to uses AJAX, my next step was going add jquery blockui and jquery validate.

  5. #4
    Jordan Guest

    Re: Submit two forms with one button

    jQuery makes AJAX calls very simple so you shouldn't have any problem. Here is information on it: API/1.3/Ajax - jQuery JavaScript Library

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Clicable image - submit button in JSP
    By toto_7 in forum Java Help
    Replies: 0
    Last Post: 05-05-2011, 06:09 PM
  2. hello , i have a problem with form submit button/input
    By alrazy1 in forum HTML Programming
    Replies: 3
    Last Post: 12-19-2010, 11:46 PM
  3. Problem with UPDATE using submit button
    By bajerocks in forum PHP Development
    Replies: 2
    Last Post: 07-01-2010, 03:54 PM
  4. Beginner ?: Why won't the submit button work?
    By jackolantern in forum PHP Development
    Replies: 3
    Last Post: 07-24-2009, 08:59 AM
  5. HTML Web Form Submit Button
    By amie654 in forum HTML Programming
    Replies: 2
    Last Post: 08-10-2008, 02:24 AM

Tags for this Thread

Bookmarks

Posting Permissions

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