脚本 复选框控制Checkboxlist 实现全选或反选
我做一个程序,想在客户端实现一个复选框控制Checkboslixst,这是程序,可是总是报错,而了调用脚本就没有问题,不知道为什么?
首先声明,我这程序里有多组checkboxlist,每一个checkboxlist都由一个复选框
<asp:CheckBox ID= "ckbfl " runat= "server " Width= "65px " OnCheckedChanged= "checkfl(CheckBoxList1, bol) "/> </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;
}
------解决方案-------------------- <asp:CheckBox ID= "ckbfl " runat= "server " Width= "65px " OnCheckedChanged= "checkfl( 'CheckBoxList1 ', bol) "/> </td>
function checkfl(objid, bol) {
var obj = document.getElementById(objid).getElementsByTagName( "INPUT ");
for (var i=0; i <obj.length; i++)
{
if(obj[i].type== "checkbox ")
obj[i].checked = bol;
}
}