繁体   English   中英

我可以一键提交两个表格吗

[英]Can I submit two forms with one button

例如,假设我有这两种形式

 <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>

我不知道如何测试它,但如果我找到了,我会尝试更新我的代码段。 :)

希望能帮助到你。

此代码有效。

<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>

也许其他人会整理它!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM