Home > Web Front-end > JS Tutorial > Submit the form through JS code

Submit the form through JS code

高洛峰
Release: 2016-12-16 15:19:54
Original
1585 people have browsed it

Submit the form through JS code, set the type of the submit button to a normal button, and then add the onclick attribute

<!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>
Copy after login


For more articles related to submitting the form through JS code, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template