当前位置:编程学习 > C#/ASP.NET >>

jQuery控制表单插入

   我的意思是说 
   想在表格中根据指定的行后面插入几行
   这几行正好在指定的那行之后插入 而不是在表单最好一行之后插入
   jQuery该怎么实现勒

   以下是我用jQuery写的源码
    var _array = $("tr", $("#Tbody1")); //获取所有行对象数组
    var intLineCount = _array.length;
    for (var i = 0; i <intLineCount; i++) {
        var tds = $("input", _array[i])
        if (tds[0].checked == true)
        {
            tr=i;
            td=tds[1].value;
            $(tds[2]).css({ color: "red"});
            $(tds[3]).css({ color: "red"});
            $(tds[4]).css({ color: "red"});
        }
    }

     var trs=$("#Tbody2").find("tr");
     for(var i=0;i<trs.length;i++){ 
     if($(trs[i]).find("input")[0].checked==true)
     { 
        var str=$(trs[i]).find("input")[2].value+"+"+$(trs[i]).find("input")[3].value+"+"+$(trs[i]).find("input")[4].value+"+"+$(trs[i]).find("input")[5].value+"+"+$(trs[i]).find("input")[6].value+"+"+$(trs[i]).find("input")[7].value;
         var idscont=document.getElementById("<%=hidCheckBox.ClientID %>");   
          idscont.value+=str+"|";
     }
     }
     var index=tr+1;
     var arr=$("input[id$='hidCheckBox']").val().split('|');
     alert($("input[id$='hidCheckBox']").val());
     for(var i=0; i<arr.length-1; i++)
     {
        var emp=arr[i].split('+');
        index+=1;
        var rehtml = "<tr id='r_" + index + "' ondblclick='gotoSelWLDH(this)' onkeyup='rowEnter(this)'>";
        rehtml += "<td style='width:50px;'><input name='r_" + index + "_Selected' type='checkbox' class='dis' /></td>";
        rehtml += "<td style='width:30px;'><input name='r_" + index + "_HH' style='width:100%;' value=" + td + "  readonly type='text' class='dis' /></td>";
        rehtml += "<td style='width:150px;'><input name='r_" + index + "_WLDH' style='color:red' value='"+emp[0]+"'  type='text'  onchange='getSelWLDH(this)' /></td>";
        rehtml += "<td style='width:200px;'><input name='r_" + index + "_WLDHName' style='color:red' value='"+emp[1]+"' type='text'  onchange='return JudgeWLDH(this);' /></td>";
        rehtml += "<td style='width:150px;'><input name='r_" + index + "_JSCS' style='color:red' type='text' value='"+emp[2]+"'  onchange='return JudgeWLDH(this);' /></td>";
        //rehtml += "<td style='width:100px;'><input name='r_" + index + "_FZ' type='text'   onchange='return JudgeWLDH(this);' /></td>";
        //rehtml += "<td><input name='r_" + index + "_DW' type='text' /></td>";
        rehtml += "<td><input name='r_" + index + "_SL' value='"+emp[3]+"' type='text'checkinfo='{need:1,len:999,dtype:1}' onkeyup=\"if(isNaN(value))execCommand('undo')\" onafterpaste=\"if(isNaN(value))execCommand('undo')\"/></td>";
        //rehtml += "<td><input name='r_" + index + "_SHL' type='text' style='width:100%;' checkinfo='{need:1,len:999,dtype:1}' onkeyup=\"if(isNaN(value))execCommand('undo')\" onafterpaste=\"if(isNaN(value))execCommand('undo')\"/></td>";
        rehtml += "<td><input name='r_" + index + "_YJWZ' value='"+emp[4]+"' type='text' style='width:100%;'  /></td>";
        rehtml +="<td style='width:90px;'><select name='r_" + index + "_GXID' style='width:100%;'>";
        rehtml +="<option value=''></option>";
        rehtml +="<%=ViewState["GX"] %>";
        rehtml +="</select></td>";
        rehtml += "<td><input name='r_" + index + "_BZ' value='"+emp[5]+"' type='text'/></td>";
        rehtml += "</tr>";
        $("#Tbody1").append(rehtml);
     }


$(trs[i]).find("input")[0].checked==true根据这个是否选中 然后在那个选中的行之后插入几行

   各位大侠 指教指教  小弟该如何实现
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,