表单传值

js提交表单
<head>
    <title></title>
    <script type="text/javascript">
        function bt() {
          
            document.getElementById("f").submit();
        }
      
    </script>
</head>
<body>
<form id="f" action="Default.aspx" method="post" >
<table>
<tr><td>yonghuming</td><td>
    <input id="Text1" name="t1" type="text" /></td></tr>
<tr><td>mima</td><td>
    <input id="Text2" name="t2" type="text" /></td></tr>
<tr><td></td><td></td></tr>
<tr><td>
   </td><td></td></tr>
</table></form>
 <input id="Button1" type="button" value="button" οnclick="bt()" />
</body>
</html>






使用提示,直接form表单提交
<form action="Default.aspx" method="post" id="f1">
<table>
<tr><td>用户名</td><td>
    <input id="Text1" name="T1" type="text" /></td></tr>
<tr><td>密码</td><td>
    <input id="Text2" name="T2" type="text" /></td></tr>
    <tr><td>
        <input type="submit" name="submit1" value="提交" οnclick="if(confirm('确认要提交表单吗'))this.f1.submit()"></td></tr>
</table>
</form>
if (HttpContext.Current.Request.HttpMethod == "POST")//是否为POST的传值方式
            {
                string 客户编号 = Request.Form["Text1"].ToString();
                string 公司名称 = Request.Form["Text2"].ToString();
                string 联系人 = Request.Form["Text3"].ToString();
                string 性别 = Request.Form["Text4"].ToString();
                string 电话 = Request.Form["Text5"].ToString();
                string 客户等级 = Request.Form["Text6"].ToString();
                string 地址 = Request.Form["Text7"].ToString();
                string 备注 = Request.Form["Text8"].ToString();
                my.sqldelete("update clientinformation set 公司名称='" + 公司名称 + "',联系人='" + 联系人 + "',性别='" + 性别 + "',电话='" + 电话 + "',客户等级='" + 客户等级 + "',地址='" + 地址 + "',备注='" + 备注 + "' where 客户编号='" + 客户编号 + "'");
                Response.Redirect("index.aspx");
            }








JQUERY提交表单
function checksubmit(){      
    $("#form1").submit();      
  }   
  
  
  ajax提交表单
  
     <script src="js/jquery-1.4.2.min.js" type="text/javascript"></script>
        <script src="js/jquery.form.js" type="text/javascript"></script>
      <script type="text/javascript">
          $(document).ready(function() {
          $('#myFormId').ajaxForm(function() {
          $(this).ajaxSubmit(); 
             });
         });
     </script>
 
<form id="myForm" action="Default.aspx" method="post">
    民资 <input type="text" id="t1" name="t1" />
     <input type="submit" value="登录"/>
</form>








ajax验证用户名是否填
<form id="validationForm" action="dummy.php" method="post"> 
    Username: <input type="text" name="username" /> 
    Password: <input type="password" name="password" /> 
    <input type="submit" value="Submit" /> 
</form>


$(document).ready(function() { 
    // bind form using ajaxForm 
    $('#myForm2').ajaxForm( { beforeSubmit: validate } ); 
});




function validate(formData, jqForm, options) { 
    // formData is an array of objects representing the name and value of each field 
    // that will be sent to the server;  it takes the following form: 
    // 
    // [ 
    //     { name:  username, value: valueOfUsernameInput }, 
    //     { name:  password, value: valueOfPasswordInput } 
    // ] 
    // 
    // To validate, we can examine the contents of this array to see if the 
    // username and password fields have values.  If either value evaluates 
    // to false then we return false from this method. 
 
    for (var i=0; i < formData.length; i++) { 
        if (!formData[i].value) { 
            alert('Please enter a value for both Username and Password'); 
            return false; 
        } 
    } 
    alert('Both fields contain values.'); 
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值