首页  ·  知识 ·  前端
Jquery控件checkboxlist实例,解决前台操作服务器控件的困难
网友     综合  编辑:dezai   图片来源:网络
var chbarray = []; line alt2 table tbody tr td clas
var chbarray = [];
var globalarrary = [];
$(document).ready(function() {
 
//将所有checkbox找出,加入到数组
$("#OrgPermissContainer tr td input[type='checkbox']").each(function(i, item) {
chbarray.push({ name: $(item).next()[0].innerHTML, value: item });
});
//将所有checkbox找出,加入到数组
$("#globalPermissionContainer tr td input[type='checkbox']").each(function(i, item) {
chbarray.push({ name: $(item).next()[0].innerHTML, value: item });
});
 
//为所有的checkbox添加事件
$("#globalPermissionContainer tr td input[type='checkbox']").click(function() {
//处理每一个checkbox的单击事件
var strId = $(this).next()[0].innerHTML;
 
 
if (strId == "添加组织" || strId == '修改组织信息' || strId == '删除组织') {
//遍历checkbox数组
 
$.each(chbarray, function(i, ele) {
if (ele.name == "查看组织信息") {
 
ele.value.checked = true;
 
}
});
}
if (strId == "添加用户" || strId == '修改用户信息' || strId == '删除用户') {
 
$.each(chbarray, function(i, ele) {
if (ele.name == "查看用户信息") {
 
ele.value.checked = true;
 
}
});
}
 
});
 
//为所有的checkbox添加事件
$("#OrgPermissContainer tr td input[type='checkbox']").click(function() {
//处理每一个checkbox的单击事件
var strId = $(this).next()[0].innerHTML;
 
 
if (strId == "添加组织" || strId == '修改组织信息' || strId == '删除组织') {
//遍历checkbox数组
/*for(var i=0;i<chbarray.length;i++)
{
if(chbarray[i].name=="查看组织信息")
{
chbarray[i].value.checked=true;
}
}*/
$.each(chbarray, function(i, ele) {
if (ele.name == "查看组织信息") {
 
ele.value.checked = true;
 
}
});
}
if (strId == "添加用户" || strId == '修改用户信息' || strId == '删除用户') {
 
$.each(chbarray, function(i, ele) {
if (ele.name == "查看用户信息") {
 
ele.value.checked = true;
 
}
});
}
 
});
 
 
 
});
 
 
</script>

  

本文作者:网友 来源:网络
CIO之家 www.ciozj.com 微信公众号:imciow
   
免责声明:本站转载此文章旨在分享信息,不代表对其内容的完全认同。文章来源已尽可能注明,若涉及版权问题,请及时与我们联系,我们将积极配合处理。同时,我们无法对文章内容的真实性、准确性及完整性进行完全保证,对于因文章内容而产生的任何后果,本账号不承担法律责任。转载仅出于传播目的,读者应自行对内容进行核实与判断。请谨慎参考文章信息,一切责任由读者自行承担。
延伸阅读