form表单提交三种方式,demo实例详解

 
  1. 第一种:使用type=submit  可以直接提交  

 
  1. <html>  
  2.  <head>  
  3.   <title>submit直接提交</title>  
  4.  </head>  
  5.   
  6.  <body>  
  7.     <!-- 表单的提交方式一 -->  
  8.     <form method="get">  
  9.         username: <input type="text" name="username"/>  
  10.         <br/>  
  11.         password: <input type="password" name="password"/>  
  12.         <br/>  
  13.         <input type="submit" value="提交"/>  
  14.     </form>  
  15.   
  16.  </body>  
  17. <script type="text/javascript">  
  18.   
  19. </script>  
  20. </html>  

 
  1. 第二种:使用type=button提交   需要得到表单的控件 使用表单空间调用自己的submit()方法  

 
  1. <pre name="code" class="html"><html>  
  2.  <head>  
  3.   <title>button提交</title>  
  4.  </head>  
  5.   
  6.  <body>  
  7.     <!-- 表单的提交方式二 -->  
  8.     <form id="form01" method="get">  
  9.         username: <input type="text" name="username"/>  
  10.         <br/>  
  11.         password: <input type="password" name="password"/>  
  12.         <br/>  
  13.         <input type="button" value="提交" onclick="form01();"/>  
  14.     </form>  
  15.  </body>  
  16. <script type="text/javascript">  
  17.     //使用button进行表单的提交  
  18.     function form01() {  
  19.         //得到form标签  
  20.         var form01 = document.getElementById("form01");  
  21.         //提交form表单  
  22.         form01.submit();  
  23.     }  
  24. </script>  
  25. </html>  

第三种:直接使用get网址 进行超链接提交



 
  1. <pre name="code" class="html"><href="html?username=ccc&password=123456">超链接提交数据</a>