<script type="text/javascript">
function SelectAll(tempControl)
{
var theBox=tempControl;
xState=theBox.checked;//标题上面CheckBox的状态
elem=theBox.form.elements;
for(i=0;i<elem.length;i++)//遍历当前表单上的所有元素
{
if(elem[i].type=="checkbox" && elem[i].id!=theBox.id)//找到除标题上的CheckBox外的所有CheckBox
{
if(elem[i].checked!=xState)
{
elem[i].click();
}
}
}
}
</script>
在全选的CheckBox 上调用 如下:
<asp:CheckBox ID="chkAll" οnclick="SelectAll(this)" runat="server" />