SOURCE Example
One: The JavaScript page automatically submits the form when it is trimmed
Form form:
The code is as follows |
Copy Code |
<form method= "POST" id= "MyForm" action= "a.php" > <input type= "Submit" value= "Submission Form" > </form> JavaScript code: <script type= "Text/javascript" > function Validate () { document.getElementById (' MyForm '). Submit (); } Window.load=validate (); </script> |
Note: When submitting a form using JavaScript, do not use id= "submit" or name= "submit", for example:
<input type= "button" name= "Submit"/> or <input type= "button" id= "submit"/> Such JS may not be compatible with a variety of browsers, will cause JS error.
Two ' hyperlinks submit the form
The code is as follows |
Copy Code |
Form form: <form method= "POST" id= "MyForm" action= "a.php" > <input type= "test" value= "name"/> </form> <a href= "javascript:validate ()" > Submit </a> JavaScript code: <script type= "Text/javascript" > function Validate () { document.getElementById (' MyForm '). Submit (); } </script> |