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.
ThanksCode:<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>
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.
ok thanks, maybe it best to uses AJAX, my next step was going add jquery blockui and jquery validate.
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
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks