例如,假设我有这两种形式
<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>
也许其他人会整理它!