后台方法
//protected void chkAll_CheckedChanged(object sender, EventArgs e)
//{
// for (int i = 0; i < this.grid.Rows.Count; i++)
// {
// ((CheckBox)grid.Rows[i].FindControl("chkItem")).Checked = ((CheckBox)this.grid.HeaderRow.FindControl("chkAll")).Checked;
// }
//}
脚本方法
function selectAll(opt)
{
var chkArray = window.document.getElementsByTagName("input");
var isCheck = opt.checked;
for(var i = 0; i< chkArray.length; i++)
{
if(chkArray[i].type != "checkbox")
{
continue;
}
if(opt != chkArray[i])
{
chkArray[i].checked = isCheck;
}
}
}
//protected void chkAll_CheckedChanged(object sender, EventArgs e)
//{
// for (int i = 0; i < this.grid.Rows.Count; i++)
// {
// ((CheckBox)grid.Rows[i].FindControl("chkItem")).Checked = ((CheckBox)this.grid.HeaderRow.FindControl("chkAll")).Checked;
// }
//}
脚本方法
function selectAll(opt)
{
var chkArray = window.document.getElementsByTagName("input");
var isCheck = opt.checked;
for(var i = 0; i< chkArray.length; i++)
{
if(chkArray[i].type != "checkbox")
{
continue;
}
if(opt != chkArray[i])
{
chkArray[i].checked = isCheck;
}
}
}
浙公网安备 33010602011771号