In js, you can use the submit method to implement the form submit function. The syntax format is "form object.submit()". This method submits the form data to the web server. The way to submit the form is the same as the user clicking the Submit button. The same, but the form's onsubmit event handler will not be called.
The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.
<html> <head> <script language="javascript" type="text/javascript"> function FormSubmit() { myFrm.action = "a.asp"; myFrm.submit(); } </script> </head> <body> <form name="myFrm"> 表单项1:<input type="text" name="tt1" /> 表单项2:<input type="text" name="tt2" /> </form> <img alt="提交" src="b.gif" width="50" height="22" style="cursor: hand" onclick="FormSubmit();" /> </body> </html>
submit() method submits form data to the web server.
Syntax
formObject.submit()
Description
This method submits the form in the same way as if the user clicks the Submit button, but the form's onsubmit event handler will not be called.
[Recommended learning: javascript advanced tutorial]
The above is the detailed content of How does Javascript implement the submit function?. For more information, please follow other related articles on the PHP Chinese website!