//全选功能的函数
function selectAll(obj, chk) {
if (chk == null)
chk = ‘chk_list‘;
var elems = obj.form.getElementsByTagName("INPUT");
if (obj.checked == true) {
for (var i = 0; i < elems.length; i++) {
if (elems[i].name == chk)
elems[i].checked = true;
}
}
else {
InvertSelection(obj);
}
}
//反选功能的函数
function InvertSelection(obj, chk) {
if (chk == null)
chk = ‘chk_list‘;
var elems = obj.form.getElementsByTagName("INPUT");
for (var i = 0; i < elems.length; i++) {
if (elems[i].name == ‘chk_list‘) {
if (elems[i].checked)
elems[i].checked = false;
else
elems[i].checked = true;
}
}
}
原文:http://www.cnblogs.com/xululublog/p/4729210.html