[英]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.