有人可以帮我解决这个问题吗
Javascript代码:
function CheckAll(pObj) {
var mCurrStatus;
mCurrStatus = pObj.checked;
var mObjList; mObjList = document.all["process"];
for (x = 0; x <= 2; x++) {
var Obj;
Obj = mObjList[x];
Obj.checked = mCurrStatus;
}
}
asp-经典代码:
response.Write "<td nowrap><input type=checkbox name=process_1 "
response.Write "/>box1</td>"
response.Write "<td nowrap><input type=checkbox name=process_2 "
response.Write "/>box2</td>"
这是我的全选框:
response.Write "<th align=left><input type=checkbox onclick=CheckAll(this)></th>"
当我单击全选框时如何选择那些框(似乎该功能不起作用)请帮助我而不是给我示例...非常感谢你们的帮助~
更新:
我参考了 Roland 的建议并制作了新功能,但没有任何想法?
功能检查所有(){
var eles = [];
var len = elems.length;
//var inputs = document.getElementsByTagName("input");
var elems = tab.getElementsByTagName("input");
for (var i = 0; i < len; i++) {
if (elems[i].name.indexOf('process_') == 0) {
eles.push(elems[i]);
}
}
//var elems = tab.getElementsByTagName("input");
for (var x = 0; x < len; x++) {
if (elems[x].type == "checkbox") {
elems[x].checked = true;
}
}
}