<html> <head> <script type="text/javascript"> function formSubmit() { fm.submit() } </script> </head> <body> <form name=fm> 名:<input type="text" name="firstname" size="20"><br /> 姓:<input type="text" name="lastname" size="20"><br /> <br /> <input type="button" onclick="formSubmit()" value="提交"> </form> </body> </html>
说明,点击button在js中执行提交,特殊之处在于form的name属性fm,fm.submit()进行执行函数,而不是利用id选择器 document.getElementById(
"form"
).submit(); 进行.submit()