您现在的位置: 365建站网 > 365文章 > GridView等中全选CheckBox

GridView等中全选CheckBox

文章来源:365jz.com 点击数:377 更新时间:2009-09-20 08:53
<script>
      //table:Gridview或Table的ClientID,columnIndex:CheckBox所在列的索引号

     

function selectGridViewAllCheckBox(gvID,columnIndex)
{
    var _this=document.getElementById(gvID);

    for(var i=1;i<_this.rows.length;i++)
    {
       if(typeof(_this.rows[i].cells[columnIndex])=="object")
       {
         for(var j=0;j<_this.rows[i].cells[columnIndex].childNodes.length;j++)
         {
           var oj=_this.rows[i].cells[columnIndex].childNodes[j];
            findChildCheckBox(oj);
         }
       }
    }
}
function findChildCheckBox(oj)
{
    var result=false;
    for(attr in oj)
    {
      if(attr=="type")
      {
        if(oj.getAttribute(attr)=="checkbox")
        {
         result=true;
         try{
               if(oj.checked==true)
               {
                  oj.checked=false;
               }
               else
               {
                 oj.checked=true;
                
               }
            }catch(e){}
        }
      }
    }
    if(!result)
    {
      for(var c=0;c<oj.childNodes.length;c++)
      {
        findChildCheckBox(oj.childNodes[c]);
      }
    }
}

</script>

生产内容,同时打通搜索引擎(SEO)与AI搜索引擎(GEO)流量入口的软件! 点击进入365建站器 »

您可能感兴趣的文章