function cbOnclick(x, y) { xs = document.getElementById(y).getElementsByTagName("input") for (i = 0; i < xs.length; i++) { if (xs[i].type == "checkbox") xs[i].checked = x.checked } }
------解决方案--------------------
cb1.Attributes["onClick"] = "cbOnclick(this,'" + cblist1.ClientID + "')"; cb2.Attributes["onClick"] = "cbOnclick(this,'" + cblist2.ClientID + "')";
function cbOnclick(x, y) { xs = document.getElementById(y).getElementsByTagName("input") for (i = 0; i < xs.length; i++) { if (xs[i].type == "checkbox") xs[i].checked = x.checked } }
------解决方案-------------------- 全选 function checkboxall(){ $("input[@type='checkbox']").each(function(){ $(this).attr("checked",true); });
}
------解决方案-------------------- 反选
function rcheckboxall(){ $("input[@type='checkbox']").each(function(){ if($(this).attr("checked")){ $(this).attr("checked",false); }else{ $(this).attr("checked",true); } });
}
------解决方案-------------------- <script language="JavaScript" type="text/javascript"> function checkall(form){ for (var i=0;i<form.elements.length;i++){ var e = form.elements[i]; if (e.name != 'chkall') e.checked = form.chkall.checked; } } </script>