使用jquery c#将多个文本框中的数据插入到sql中 [英] insert data from multiple textboxes to sql using jquery c#

查看:75
本文介绍了使用jquery c#将多个文本框中的数据插入到sql中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个文本框可以通过使用以下代码点击添加按钮来复制

i have two text boxes that can be duplicated by clicking on add button using following code

<table  id="tbl1"  class="form-group">
           <tr><td class="col-sm-1">Code:</td><td class="col-sm-1"><input type="number" data-type="number" id="Code"/></td><td class="col-sm-1">Fine:</td><td><input type="text" id="Fine" placeholder="Fine"/></td> <td> <a href="java<!-- no -->script:void(0);" id='anc_add' class="btn btn-green">Add Code</a></td>
      <td><a href="java<!-- no -->script:void(0);" id='anc_rem' class="btn btn-red ">Remove Code</a></td></tr>
           </table>



jquery代码是


jquery code is

<script>
           $(document).ready(function () {
               var cnt = 2;
               $("#anc_add").click(function () {
                   $('#tbl1 tr').last().after('<tr><td class="col-sm-1"> Code:' + cnt + '</td><td  class="col-sm-1"><input type="number"  id="Code' + cnt + '" placeholder="Code"></td><td class="col-sm-1"> Fine:' + cnt + '</td><td><input type="text" id="Fine' + cnt + '" readonly="readonly" placeholder="Fine"></td></tr>');
                   cnt++;
               });

               $("#anc_rem").click(function () {
                   if ($('#tbl1 tr').size() > 1) {
                       $('#tbl1 tr:last-child').remove();
                   }
                   else {
                       alert('One row should be present in table');
                   }
               });
               var getval = $('input[data-type="number"]').val;
           });
</script>



i希望从每个文本框中获取代码和精细值,这些文本框可能是一两个,并将它们保存在表格中

其中列为


i want to get code and fine value from each textbox which may be one two so on and save them in a table
which have column as

id Code  Fine

推荐答案

document )。ready( function (){
var cnt = 2 ;
(document).ready(function () { var cnt = 2;


< span class =code-string>#anc_add)。click( function (){
("#anc_add").click(function () {


' #tbl1 tr')。last()。after(' < tr>< td class =col-sm-1>代码:' + cnt + ' < / td>< td class =col-sm-1>< input type =numberid =Code + cnt + ' placeholder =Code>< / td>< td class =col -sm-1\" >好的:' + cnt + ' < / td>< td>< input type = textid =Fine' + cnt + ' readonly =readonlyplaceholder =Fine >< / TD>< / TR>');
cnt ++;
});
('#tbl1 tr').last().after('<tr><td class="col-sm-1"> Code:' + cnt + '</td><td class="col-sm-1"><input type="number" id="Code' + cnt + '" placeholder="Code"></td><td class="col-sm-1"> Fine:' + cnt + '</td><td><input type="text" id="Fine' + cnt + '" readonly="readonly" placeholder="Fine"></td></tr>'); cnt++; });


这篇关于使用jquery c#将多个文本框中的数据插入到sql中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆