现在的位置: 首页 > 综合 > 正文

JS 实现GridView中CheckBox全选

2013年02月04日 ⁄ 综合 ⁄ 共 314字 ⁄ 字号 评论关闭

 function SelectAll(tempControl)
{
  var theBox=tempControl;
  xState=theBox.checked;  
  elem=theBox.form.elements;
  for(i=0;i<elem.length;i++)
  if(elem[i].type=='checkbox' && elem[i].id!=theBox.id)
  {
  if(elem[i].checked!=xState)
  elem[i].click();
   
  }
}

 

 

调用代码:<asp:CheckBox ID="allCheck" runat="server" onclick="SelectAll(this);" />

抱歉!评论已关闭.