0
我試圖通過另一種形式定義的按鈕提交窗體時出現問題。多個窗體的交互
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test submit</title>
</head>
<body>
<form id="dummyForm" name="dummyForm">
<button onclick="sendTheForm();">Submit other form</button>
</form>
<form id="formID" name="formName" action="viewpost.php" method="POST">
<input type="hidden" value="something" id="inputA1" name="inputA1" />
<input type="hidden" value="something" id="inputA2" name="inputA2" />
</form>
<script type="text/javascript">
function sendTheForm() {
document.forms['formName'].submit();
}
</script>
</body>
</html>
實現重定向按預期的方式更改以下行的唯一方法:我不明白的是,表單提交這樣工作
onclick="sendTheForm();return false;"
。誰能解釋一下?
提前致謝!
特定的按鈕不是提交類型,所以我不明白爲什麼虛擬表單首先提交觸發器。 **按鈕的默認動作是什麼?**答案:[按鈕參考](http://w3c.github.io/html-reference/button.html) – nhereveri 2015-01-27 01:32:41
@nhereveri - 它**是**提交類型。您指向的鏈接說:*沒有指定type屬性的button元素表示與type屬性設置爲「submit」的button元素相同的東西* – Quentin 2015-01-27 10:32:06
是的。幾分鐘後,我檢查了第二步。 – nhereveri 2015-01-27 20:49:25