我可以一键提交两个表格吗 [英] Can I submit two forms with one button
本文介绍了我可以一键提交两个表格吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如,说我有这两种形式
For example, say I have these two forms
<form method="post" action="/lorum/ipsum/dolor/sit/amet">
<!-- Some stuff -->
</form>
<form method="post" action="some/other/location/here">
<!-- Some stuff -->
</form>
<button> </button> <!-- this is going to submitboth forms
我希望这是有道理的
推荐答案
类似的方法:
document.getElementById("submit").onclick = function() {
document.getElementById("form1").submit();
document.getElementById("form2").submit();
}
<form id="form1" method="post" action="/lorum/ipsum/dolor/sit/amet">
<!-- Some stuff -->
</form>
<form id="form2" method="post" action="some/other/location/here">
<!-- Some stuff -->
</form>
<button id="submit">Submit forms</button>
我不知道如何进行测试,但是如果发现,我会尝试更新我的代码段.:)
I don't know how to test it, but I'll try to update my snippet if I found. :)
希望有帮助.
这篇关于我可以一键提交两个表格吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文