源代码
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>编程字典</title> <script> function formSubmit() { document.forms["myForm"].submit(); } </script> </head> <body> <form name="myForm" action="form_submit.php" method="get"> First name: <input type="text" name="fname"><br> Last name: <input type="text" name="lname"><br><br> <input type="button" onclick="formSubmit()" value="发送表单数据!"> </form> <p>注意 在头部的 JavaScript ,使用form表单的名称提交表单</p> </body> </html>
运行结果