我实现的是Checkbox控制单个CheckboxList,报如下错误: 'undefined '为空或不是对象
<input id= "Checkbox1 " type= "checkbox " onclick= "checkfl( 'CheckBoxList1 ',this.checked) " checked= "checked "/> </td>
脚本:
<script language= "javascript " id= "onclick ">
function checkfl(obj, bol) {
if (typeof(obj)== "undefined ");
else if (typeof(obj.length)== "undefined ")
obj.checked = bol;
else
for (var i=0; i <obj.length; i++)
obj[i].checked = bol;
}
不知为何
------解决方案--------------------------------------------------------
obj是字符串类型
function checkfl(obj, bol) {
var objs = document.getElementById(obj).getElementsByTagName( "INPUT ");
for (var i=0; i <objs.length; i++)
if(obj[i].type== "checkbox ")
obj[i].checked = bol;
}