zoukankan      html  css  js  c++  java
  • 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>  
  • 相关阅读:
    JS 中 console 的用法
    C#可扩展编程之MEF学习笔记(二):MEF的导出(Export)和导入(Import)
    C#可扩展编程之MEF学习笔记(一):MEF简介及简单的Demo
    MEF框架使用总结
    webfunny前端监控开源项目
    我从Vue源码中学到的一些JS编程技巧
    nodejs 发送邮件demo
    从零开始手写Promise
    概率论要点
    行列式技巧
  • 原文地址:https://www.cnblogs.com/zouyun/p/7793426.html
Copyright © 2011-2022 走看看