admin管理员组文章数量:1406949
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
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
I hope this makes sense
Share asked May 3, 2018 at 14:29 Lewis ClarkeLewis Clarke 692 silver badges13 bronze badges 2-
You can write javascript to handle
click
on the button and make requests manually. – Jagdeep Singh Commented May 3, 2018 at 14:31 - 1 why would you do that ? what are you trying to achieve ? – Muhammad Usman Commented May 3, 2018 at 14:32
2 Answers
Reset to default 5Something like that works:
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. :)
Hope it helps.
this code works.
<SCRIPT LANGUAGE="JavaScript">
<!--
function SubmitBoth()
{
document.frm1.submit();
document.frm2.submit();
}
//-->
</SCRIPT>
<form name="frm1" target="formresponse1" action="send1.php" method="post">
</FORM>
<form name="frm2" target="formresponse2" action="send2.php" method="post">
</FORM>
<INPUT TYPE="button" value="SubmitBoth" onClick="SubmitBoth()">
<iframe name='formresponse1' width='300' height='200'></frame>
<iframe name='formresponse2' width='300' height='200'></frame>
maybe someone else will tidy it up!
本文标签: javascriptCan I submit two forms with one buttonStack Overflow
版权声明:本文标题:javascript - Can I submit two forms with one button - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744879600a2630125.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论