例如,假设我有这两种形式
<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
&#13;
我希望这是有道理的
答案 0 :(得分:2)
类似的东西:
document.getElementById("submit").onclick = function() {
document.getElementById("form1").submit();
document.getElementById("form2").submit();
}
&#13;
<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>
&#13;
我不知道如何测试它,但如果我发现,我会尝试更新我的代码段。 :)
希望它有所帮助。
答案 1 :(得分:0)
此代码有效。
<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>
也许其他人会整理它!