Is to possible to submit two forms simultaneously?

前端 未结 6 561
说谎
说谎 2020-12-21 13:42

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

Form structure is ok something like this:

6条回答
  •  有刺的猬
    2020-12-21 14:15

    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.

提交回复
热议问题