Form submit() 方法

定義和用法
submit() 方法用于提交表單 (點(diǎn)擊 Submit 按鈕)。
語法
formObject.submit()
瀏覽器支持
所有主要瀏覽器都支持 submit() 方法
實(shí)例
實(shí)例
創(chuàng)建一個表單提交按鈕:
<html>
<head>
<script>
function formSubmit()
{
document.getElementById("frm1").submit();
}
</script>
</head>
<body>
<form id="frm1" action="form_action.html">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="button" onclick="formSubmit()" value="Submit form">
</form>
</body>
</html>
<head>
<script>
function formSubmit()
{
document.getElementById("frm1").submit();
}
</script>
</head>
<body>
<form id="frm1" action="form_action.html">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="button" onclick="formSubmit()" value="Submit form">
</form>
</body>
</html>
嘗試一下 ?

更多建議: