用链接提交表单

 一般人都会用<input type="submit" />来提交表单,这是最直接的方式.可有些人就是觉得用按钮提交感觉怪怪的(按钮形状是凸起的!我一个同学就是不爽这个).

于是就想啊用链接提交.下面是一个例子.

<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< html  xmlns ="http://www.w3.org/1999/xhtml"   >
< head >
    
< title > 无标题页 </ title >

</ head >
< body >
< form  id ="form1"  method ="post"  action ="testForm.aspx" >
用户名:
< input  type ="text"  id ="txtname"  name ="txtname"   />< br  />
密  码:
< input  type ="password"  id ="txtpwd"  name ="txtpwd"   />< br  />

</ form >
    
< script >
    
function aaa()
    
{
        document.forms(
0).submit();
        
//document.form1.submit();
    }

    
</ script >
< href ="#"  onclick ="aaa()" > 提交 </ a >
</ body >
请注意form标签的method属性和action属性,这两个属性决定了你把内容提交到了哪个页面.这里提交到的是testForm.aspx页面,于是可以在这个页面上这样取到传过来的值:
// 这段代码写在page_load中 
string  name  =  Request.Form[ " txtname " ].ToString();
        
string  password  =  Request.Form[ " txtpwd " ].ToString();
        Response.Write(
" 用户名: "   +  name  +   " 密码: "   +  password);
以上就是怎么用链接提交表单的例子,很简单.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值