function checkAll() {
//把所有参与选择的checkbox使用相同的name,这里为"num_iid"
var eles = document.getElementsByName("num_iid");
var i = 0;
// 如果是全选状态,则取消所有的选择
if (isSelectAll() == true) {
for ( i = 0; i < eles.length; i++) {
eles[i].checked = false;
}
document.getElementById("selectAll").checked = false;
} else {
// 否则选中每一个checkbox
for ( i = 0; i < eles.length; i++) {
eles[i].checked = true;
}
}
}
// 判断当前是否为全选状态
function isSelectAll() {
var isSelected = true;
var eles = document.getElementsByName("num_iid");
for (var i = 0; i < eles.length; i++) {
if (eles[i].checked != true) {
isSelected = false;
}
}
return isSelected;
}
// 选择任意一个非全选checkbox
function checkOne() {
if (isSelectAll()) {
document.getElementById("selectAll").checked = true;
} else {
document.getElementById("selectAll").checked = false;
}
}