I have a Checkbox and disabled Radiobuttonlist in same table row and different td and just trying to enable/disable it when I check/uncheck a checkbox.
<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>
This is how original server-side html looks like:
<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 am trying something obvious to do that, 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 doesn't work, but logically it should. What am I doing wrong here?