关于checkbox操作 table
引入 Validform验证
<script type="text/javascript">
//添加操作
crrTrTdCkId=1;
function addIndexBtnClick(){
crrTrTdCkId=crrTrTdCkId+1
crrTrTdCkIdStr="CkId"+crrTrTdCkId
var insertTr=
'<tr >'+
'<td align="center" ><input type="checkbox" name="ck" id="'+crrTrTdCkIdStr+'"/></td>'+
'<td > <input name="dxName" type="text" datatype="*1-50" style="width:120px" ><span class="Validform_checktip"></span><label class="Validform_label" style="display: none;">名称</label></td>'+
'<td > <input name="dxgrade" type="text" datatype="n1-2" style="width:40px" ><span class="Validform_checktip"></span><label class="Validform_label" style="display: none;">分数</label></td>'+
'<td > <input name="remark" type="text" datatype="*0-150" style="width:250px" ><span class="Validform_checktip"></span><label class="Validform_label" style="display: none;">备注</label></td>'+
'</tr>'
$("#addPosition").after(insertTr);
$("#addPosition").remove();
$("#"+crrTrTdCkIdStr).parent().parent().after('<input id="addPosition" type="hidden"/>')
}
//删除操作
function delIndexBtnClick(){
if($("input[name='ck']:checked").length==0){
tip("至少选择一条进行删除操作");
}else{
$('input[name="ck"]:checked').each(function(){
$(this).parent().parent().remove();
});
}
}
//全选 全不选 jq操作
$(function(){
$("#dxBox").click(function(){
if($("#dxBox").val()==0){
$('input[name="ck"]').attr("checked","true");
$("#dxBox").val("1")
}else{
$('input[name="ck"]').removeAttr("checked");
$("#dxBox").val("0")
}
});
})
</script>
<style type="text/css">
.formtable1 td{ border:1px solid #ddd;height:38px}
</style>
</head>
<body style="overflow-x: hidden;">
<div style="height:25px" class="datagrid-toolbar">
<a id="addColumnBtn1" class="easyui-linkbutton" data-options="iconCls:'icon-add'" onclick="addIndexBtnClick();" href="#">添加</a>
<a id="delColumnBtn1" class="easyui-linkbutton" data-options="iconCls:'icon-remove'" onclick="delIndexBtnClick();" href="#">删除</a>
<%--<span style="color:#000000;font-size:16px">点选项明细</span>--%>
</div>
<table class="formtable1" cellpadding="0" cellspacing="0" width="100%" >
<tr>
<td align="center" width="5%" > <input type="checkbox" value="0" id="dxBox" /></td>
<td align="center" width="30%" ><b>名称</b></td>
<td align="center" width="15%" ><b>分数</b></td>
<td align="center" width="50%" ><b>备注</b></td>
</tr>
<c:forEach items="${dxList }" var="v1" varStatus="status">
<tr>
<td align="center" valign="middle" >
<input type="checkbox" name="ck" id="trForCK${status.index+1}"/>
</td>
<td>
<input name="dxName" value="名称1" type="text" datatype="*1-50" style="width:120px" >
<span class="Validform_checktip"></span>
<label class="Validform_label" style="display: none;">名称</label>
</td>
<td >
<input name="dxgrade" value="1" type="text" datatype="n1-2" style="width:40px" >
<span class="Validform_checktip"></span>
<label class="Validform_label" style="display: none;">分数</label>
</td>
<td>
<input name="remark" value="备注1" type="text" datatype="*0-150" style="width:250px">
<span class="Validform_checktip"></span>
<label class="Validform_label" style="display: none;">备注</label>
</td>
</tr>
</c:forEach>
<input id="addPosition" type="hidden"/>
</table>