Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Regular Coder
    Join Date
    Feb 2009
    Posts
    119
    Thanks
    7
    Thanked 0 Times in 0 Posts

    CheckBoxList in JavaScript

    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:
    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)
            {
    		………..	
    		………..
    	  }
    }
    
    }
    Here I am posting my generated SOURCE code
    <tr>
    <td><span disabled="disabled"><input id="ctl00_ContentPlaceHolder1_cblRoles_0" type="checkbox" name="ctl00$ContentPlaceHolder1$cblRoles$0" checked="checked" disabled="disabled" /><label for="ctl00_ContentPlaceHolder1_cblRoles_0">Admin</label></span>

    </td>
    </tr>

    <tr>
    <td><input id="ctl00_ContentPlaceHolder1_cblRoles_1" type="checkbox" name="ctl00$ContentPlaceHolder1$cblRoles$1" /><label for="ctl00_ContentPlaceHolder1_cblRoles_1">Electrichain</label>

    </td>
    </tr>

    <tr>
    <td><input id="ctl00_ContentPlaceHolder1_cblRoles_2" type="checkbox" name="ctl00$ContentPlaceHolder1$cblRoles$2" /><label for="ctl00_ContentPlaceHolder1_cblRoles_2">Painter</label>

    </td>
    </tr>

    <tr><td><input id="ctl00_ContentPlaceHolder1_cblRoles_3" type="checkbox" name="ctl00$ContentPlaceHolder1$cblRoles$3" /><label for="ctl00_ContentPlaceHolder1_cblRoles_3">Tenant</label></td>
    </tr>
    Last edited by asifakhtar; 03-13-2009 at 02:17 AM.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •