客户端全部选中或取消Repeater中的CheckBox

时间:2022-03-27 10:28:12

<script>
        // 全选
        function allCheck()
        {
            for (var i=0;i<aspnetForm.elements.length;i++)
            {
                var e=aspnetForm.elements[i];
                if (e.type=='checkbox')
                e.checked=true;
                 e.text ="全选";
            }

        }
        //反选
        function revCheck()
        {
            for (var i=0;i<aspnetForm.elements.length;i++)
            {
            var e=aspnetForm.elements[i];
            if (e.type=='checkbox')
            e.checked= false;
            e.text ="取消";
            }
        }
       
        function CheckBoxSelect()
        {
           var cb=document.getElementById("cbAll");
           if(cb.checked)
           {
              allCheck();
           }
           else
           {
             revCheck();
           }
        }
</script>