当前位置:Gxlcms > JavaScript > 通过JS代码提交(submit)表单

通过JS代码提交(submit)表单

时间:2021-07-01 10:21:17 帮助过:8人阅读

通过JS代码提交(submit)表单,将提交按钮的类型设置为普通button,然后添加onclick属性

<!DOCTYPE html>    
<html>    
<head>    
<script>    
function formSubmit()    
{    
document.getElementById("frm1").submit();    
}    
</script>    
</head>    
<body>    
<p>Enter some text in the fields below, then press the "Submit form" button to submit the form.</p>    
<form id="frm1" action="form_action.asp">    
First name: <input type="text" name="fname"><br>    
Last name: <input type="text" name="lname"><br><br>    
<input type="button" onclick="formSubmit()" value="Submit form">    
</form>    
</body>    
</html>


更多通过JS代码提交(submit)表单相关文章请关注PHP中文网!

人气教程排行