...

View Full Version : CheckBoxList in JavaScript



asifakhtar
03-11-2009, 09:41 PM
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)
{
………..
………..
}
}

}


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>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum