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>  
  • 相关阅读:
    Android不规则瀑布流照片墙的实现+LruCache算法
    嵌入式OS入门笔记-以RTX为案例:六.RTX的任务调度
    Oracle backgroup processes
    Android中数据库的操作流程详解
    Dreamweaver PHP代码护眼配色方案
    Twitter 新一代流处理利器——Heron 论文笔记之Heron架构
    Docker简单介绍
    C#下使用GDAL
    Android:实现仿 美团/淘宝 多级分类菜单效果
    KVC在定义Model类中的妙用
  • 原文地址:https://www.cnblogs.com/zouyun/p/7793426.html
Copyright © 2011-2022 走看看