form 表单提交的另一种方式 js

<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()

原文地址:https://www.cnblogs.com/zytcomeon/p/13229400.html