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

高洛峰
高洛峰 原创
2016-12-16 15:19:54 1153浏览

通过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中文网!

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。