例如,假设我有这两种形式
<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>
我不知道如何测试它,但如果找到的话我会尝试更新我的代码片段。 :)
希望有帮助。
关于javascript - 我可以一键提交两份表格吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50157532/