CheckBoxList in JavaScript Problem

Discussion in 'JavaScript' started by asifakhtar, Mar 12, 2009.

  1. #1
    I have an asp:CheckBoxList named cblRoles with values. The values are coming from the database and can be in any order in cblRoles. When I check enabled “Admin” option from cblRoles my JavaScript function CheckAdmin’s IF STATEMENT executes but when I check enabled “Admin” option from cblRoles and make “Admin” option DISABLE, listControl.checked in the IF STATEMENT doesn’t execute. I want the IF STATEMENT to execute as well when the “Admin” option is checked & DISABLE


    Here is my JavaScript code:
    
    
    function CheckAdmin(source, args) 
    {
        args.IsValid = false;  
         
        var cblRoles = document.getElementById('<%= cblRoles.ClientID %>');   
               
        var num = cblRoles.childNodes[0].childNodes.length; 
    
        var currentTable = cblRoles.childNodes[0];     
        
         
        for (var i=0 ; i<num ; i++) 
        {
            var InnetText = currentTable.childNodes[i].childNodes[0].innerText;
            
            var currentTd = currentTable.childNodes[i].childNodes[0]; 
            
            var listControl = currentTd.childNodes[0]; 
                                   
            if (InnetText=="Admin" && listControl.checked)
            {
    		………..	
    		………..
    	  }
    }
    
    }
    
    
    Code (markup):

     
    asifakhtar, Mar 12, 2009 IP