Link to home
Start Free TrialLog in
Avatar of msasikala
msasikala

asked on

Checkboxlist in Javascript

Hello,

I have got a checkboxlist in asp.net 2.0 with items populating from Database.

After populating items from Database. I'm insert a new item "Select All"  into to the checkboxlist.

I need actually, a javascript help. When I'm checking the "Select All" checkbox from the checkboxlist it is selecting all the checkboxes inside the checkboxlist and when I'm unchecking "Select All" checkbox javascript function is unchecking all checkboxes in the checkboxlist.  But, when I'm trying to check or uncheck  any checkbox other than "Select All", it is not allowing to check or uncheck.

Here is the javascript function that I'm using.
function CheckUncheckAllItems(checkBoxListId,numOfItems)
{
        var objCtrl;
       
        objCtrl = document.getElementById(checkBoxListId.id + '_' + 0);
         
         
        if (objCtrl != null && objCtrl.checked == true)
        {
             for(i = 0; i < numOfItems; i++)
            {
               
                objItem = document.getElementById(checkBoxListId.id + '_' + i);
             
                if(objItem == null)
                {
                    continue;
                }
                objItem.checked = true;
               
            }      
         }
         
         if (objCtrl != null && objCtrl.checked == false)
         {
             for(i = 0; i < numOfItems; i++)
            {
               
                objItem = document.getElementById(checkBoxListId.id + '_' + i);
               
                if(objItem == null)
                {
                    continue;
                }
                objItem.checked = false;
               
            }
         }
 
}

Please give me a solution as this one of my project requirment. I need it urgently.
Quick response will be highly appriciated
ASKER CERTIFIED SOLUTION
Avatar of LeeHenry
LeeHenry

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial