1、jsp页面的全选框
<input οnclick="swapCheck()" name="checkbox" type="checkbox" value="no">
2、删除按钮
<input type="button" class="layui-btn" οnclick="return deptDelete()" value="删除">
3、js中的全选框的事件触发
var isCheckAll = false;
function swapCheck() {
if (isCheckAll) {
$("input[type='checkbox']").each(function() {
this.checked = false;
});
isCheckAll = false;
} else {
$("input[type='checkbox']").each(function() {
this.checked = true;
});
isCheckAll = true;
}
}
4、删除事件触发后,根据复选框事件的触发,获取对应复选框的id,和删除操作
function deptDelete() {
var dept_id = $("input[name='checkbox']:checked").serialize(); //获取对应复选框的id
var cheack = dept_id.split("&"); //分割字符串为数组
var msg = "确定删除该条信息?"; //删除时弹出是否确定删除的选择弹窗
if(cheack==""||cheack==null){
alert("请选择要删除的对象");
}else{
if (confirm(msg)==true){
if(cheack[0]=="checkbox=no"){ //排除全选框
var num = new Array();
for(var i=1;i<cheack.length;i++){
num.push([cheack[i]]);
}
window.open("/dcweb/department/delete?cheack="+num,"_self"); //传要删除的id1到后台进行删除操作
return false;
}else{
window.open("/dcweb/department/delete?cheack="+cheack,"_self");
return false;
}
}else{
return false;
}
}
}