I have a checkbox and Radiobuttonlist is disabled in the same row of the table and different td and just trying to enable / disable it when I check / uncheck it.
<tr class = "main">
<td colspan="2">
<input id="CheckOne" type="checkOne" name="checkOne" />
<label for="CheckOne">Some Text</label>
</td>
<td align="center">
<table id="RadioButtonListOne" disabled="disabled" title="Choices" border="0">
<tr>
<td>
<span disabled="disabled">
<input id="RadioButtonListOne_0" type="radio" name="RadioButtonListOne" value="Y" disabled="disabled" />
<label for="RadioButtonListOne_0">Yes</label></span>
</td>
<td>
<span disabled="disabled"><input id="RadioButtonListOne_1" type="radio" name="RadioButtonListOne" value="N" disabled="disabled" />
<label for="RadioButtonListOne_1">No</label>
</span>
</td>
</tr>
</table>
</td>
</tr>
Here is the server side source html:
<tr class = "main">
<td colspan="2">
<asp:CheckBox ID="CheckBoxOne" runat="server" Text="Some Text"/>
</td>
<td align="center">
<asp:RadioButtonList ID="RadioButtonListOne" RepeatDirection="Horizontal">
<asp:ListItem Value="Y">Yes asp:ListItem>
<asp:ListItem Value="N">No</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
For some reason, when I try to do something obvious, i.e.
$('#<%= CheckBoxOne.ClientID %>').click(function()
{
if ($(this).is(":checked"))
{
$('#<%= RadioButtonListOne.ClientID%> input:radio').removeAttr('disabled');
}
else
{
$('#<%= RadioButtonListOne.ClientID%> input:radio').attr('disabled', 'disabled');
}
});
then it does not work, but logically it should be. What am I doing wrong here?
source
share