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%;"> 章 节 项:</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>