Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is to possible to submit two forms simultaneously?

Is to possible to submit two forms simultaneously with either javascript or a submit button?

Form structure is ok something like this:

<form name="form1" method="post">
.........
</form>

<form name="form2" method="post">
.........
</form>

And get the data from the two in a array?

like image 369
Sarfraz Avatar asked Aug 03 '26 03:08

Sarfraz


1 Answers

No, this is not possible. You can create a third hidden form, that will serialize fields from both of them.

If you can use jQuery:

var str1 = $("form1").serialize();
var str2 = $("form2").serialize();
$.post(url, str1 + "&" + str2);

You need to make sure that str1 and str2 aren't empty and of course avoid name conflicts between the two forms.

like image 197
kgiannakakis Avatar answered Aug 05 '26 16:08

kgiannakakis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!