js实现一个Gridview或多个Gridview中多个CheckBox的全反、反选

function CheckAll(ctlName,chb,sec) {
var ctl = document.getElementById ctlName);
var checkbox = ctl.getElementsByTagName("input");
for (var i = 0; i < checkbox.length; i++) {
if (checkbox[i].type == "checkbox"&& checkbox[i].name.indexOf(chb) > -1) {
if (sec == 1) {
checkbox[i].checked = true;
}
else {
checkbox[i].checked = false;
}
}
}
}

ctlName为Gridview的ID,chb为Gridview中Checkbox的ID

你可能感兴趣的:(checkbox)