<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html lang="zh-CN" xml:lang="zh-CN" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> <script type="text/javascript"> function formSubmit() { document.forms["myForm"].submit(); } </script> </head> <body> <form name="myForm" action="form_action.php" method="get"> 名字:<input type="text" name="fname" /><br />姓氏: <input type="text" name="lname" /><br /><br /> <input type="button" onclick="formSubmit()" value="发送表单数据!" /> </form> <p>注意:<head>中的JavaScript代码用表单名称来指明提交哪个表单。</p> </body> </html>
结果:
编辑上面的代码,点击查看结果。
yige.org
- 试一个