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