• js 增加删除表格的行


     function delThisRow(obj,rowNum)  
       {
         var ifNum = num + 1;
         //alert("num="+num);
         //alert("rowNum="+rowNum);
         if(ifNum!=rowNum)
         {
          alert("请先删除最后一行!");
          return;
         }
         num--;
         var table1 = document.getElementById("firstTB");
         table1.firstChild.removeChild(obj.parentNode.parentNode);
       }

    $(document).ready(function(){
            $("#addCheckListType").click(function(){
            num++;
            var str =  '<tr id="first">'
         + '   <td style= "20%;text-align:center;">'
         + '  <label/>SECTION'+ (num+1) +'</label>    '
         + '  <input type="hidden" name="UP_CHECKLIST_SECTION_CODE" id="UP_CHECKLIST_SECTION_CODE" value="SECTION'+ (num+1) +'"/>'
         + ' </td>              '
         + ' <td style= "20%;text-align:center;">    '
         + '  <input name="UP_CHECKLIST_SECTION_NAME" id="UP_CHECKLIST_SECTION_NAME" type="text" value="" size="10"/> '
         + ' </td>     '
         + ' <td style= "20%;text-align:center;"> '
         + '  <input name="UP_CHECKLIST_SECTION_SORTNO" id="UP_CHECKLIST_SECTION_SORTNO" type="text" required label="排序号" error="不能为空,且必须是数字" rule="number" value="" size="10"/> '
         + ' </td> '
         + ' <td style= "10%;text-align:center;"> '
         + '  <img src="<%=path%>/includes/images/remove.png" width="16" height="16"  onclick="delThisRow(this,'+(num+1)+');"/> '
         + ' </td> '
         + ' </tr>';
      //alert(str);  
      $("#firstTB").append(str);
        });
       
    }); 

    <div style="align:center;100%;margin-top:20px;" >
         <tr >
          <td colspan="1" style="text-align:center;"><font style="color:#6fade1;font-size:120%;">&nbsp;&nbsp;章&nbsp;&nbsp;节&nbsp;&nbsp;项:</font></td>
          <td ><img src="<%=path%>/includes/images/add.png" width="16" height="16" id="addCheckListType" /></td>
         </tr>
        </div>
        <table id="firstTB"  style="align:center;100%;margin-top:20px;" >
         <tr>
          <td style= "20%;text-align:center;">
           章节编号
          </td>
          <td style= "20%;text-align:center;">
           章节名称
          </td>
          <td style= "20%;text-align:center;">
           排序号
          </td>
          <td style= "20%;text-align:center;">
           操作
          </td>
         </tr>
         <%
          if(v_rs!=null && v_rs.size()>0)
          {
           for(int i=0; i<v_rs.size(); i++)
           {
           Record v_rs_rd = v_rs.get(i);
         %>
          <tr>
             <td style= "20%;text-align:center;">
            <label/><%=v_rs_rd.getString("CHECKLIST_SECTION_CODE","") %></label>
            <input type="hidden" name="UP_CHECKLIST_SECTION_CODE" id="UP_CHECKLIST_SECTION_CODE" value="<%=v_rs_rd.getString("CHECKLIST_SECTION_CODE","") %>"/>
           </td>
           <td style= "20%;text-align:center;">
            <input name="UP_CHECKLIST_SECTION_NAME" id="UP_CHECKLIST_SECTION_NAME" type="text" value="<%=v_rs_rd.getString("CHECKLIST_SECTION_NAME","") %>" size="10"/>
           </td>
           <td style= "20%;text-align:center;">
            <input name="UP_CHECKLIST_SECTION_SORTNO" id="UP_CHECKLIST_SECTION_SORTNO" type="text" required label="排序号" error="不能为空,且必须是数字" rule="number" value="<%=v_rs_rd.getString("CHECKLIST_SECTION_SORTNO","") %>" size="10"/>
           </td>
           <td style= "10%;text-align:center;">
            <img src="<%=path%>/includes/images/remove.png" width="16" height="16" onclick="delThisRow(this,'<%=i+1 %>');" />
           </td>
          </tr>
         <%
           }
          }else{
         %>
          <tr>
             <td style= "20%;text-align:center;">
            <label/>SECTION1</label>
            <input type="hidden" name="UP_CHECKLIST_SECTION_CODE" id="UP_CHECKLIST_SECTION_CODE" value="SECTION1"/>
           </td>
           <td style= "20%;text-align:center;">
            <input name="UP_CHECKLIST_SECTION_NAME" id="UP_CHECKLIST_SECTION_NAME" type="text" value="" size="10"/>
           </td>
           <td style= "20%;text-align:center;">
            <input name="UP_CHECKLIST_SECTION_SORTNO" id="UP_CHECKLIST_SECTION_SORTNO" type="text" required label="排序号" error="不能为空,且必须是数字" rule="number" value="" size="10"/>
           </td>
           <td style= "10%;text-align:center;">
            <img src="<%=path%>/includes/images/remove.png" width="16" height="16" onclick="delThisRow(this,1);" />
           </td>
          </tr>
          <%
           }
           %>
        </table>

    每一天都要行动,在前进中寻求卓越。
  • 相关阅读:
    网站实时信息采集和统计graphite
    内存检查工具Valgrind
    usr/bin/ld: cannot find 错误解决方法和 /etc/ld.so.conf
    通用makefile
    关于/proc/进程idpid/fd ,根据fd来查找连接
    boost enable_shared_from_this
    cdll和windll的差别
    一些项目——空白格式化
    Session笔记
    黑马程序猿_7K面试题之交通灯系统
  • 原文地址:https://www.cnblogs.com/wshsdlau/p/2556470.html
Copyright © 2020-2023  润新知