1个按钮提交两个表格 [英] submit two forms in 1 button
本文介绍了1个按钮提交两个表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试同时提交2个表格我试图将1个表格发送到我的数据库,而另一个发送到另一个站点
i am trying to submit 2 forms at the same time im trying to send 1 form to my DB and the other to a different site
我的代码就像:
function submitform(){
document.forms["form2"].submit();
document.forms["form1"].submit();
}
<form name="form1" action="1.php" method="post">
<!-- ... -->
</form>
<form name="form2" action="2.php" method="post" target="foo">
<!-- ... -->
</form>
<a onclick="submitform();">Go</a>
现在,如果我仅提交form2,它将在新选项卡中打开并起作用,但是当我尝试同时提交两个表单时,它将仅提交form1我不知道为什么
now if i submit only form2 it opens in a new tab and works but when i try to submit both of them it only submits form1 i have no idea why
任何帮助将不胜感激
谢谢
推荐答案
Marc B 的评论>
您一次只能提交一种格式.在提交之前,您必须以某种方式将表单合并为一个表单.
You can only submit a single format at a time. You'll have to combine the forms into a single one somehow prior to submission.
是我的答案.
这篇关于1个按钮提交两个表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文