tags:

views:

176

answers:

1

On my pages I have a table with rows that typically look like this:

<tr class = "child">
       <td>
             <asp:CheckBox ID="CheckBoxEyeProblems" runat="server" />

       </td>
       <td align="center">
             <asp:RadioButtonList ID="RadioButtonListEyeProblems" 
                <asp:ListItem Value="Y">Yes</asp:ListItem>
                <asp:ListItem Value="N">No</asp:ListItem>
             </asp:RadioButtonList>
       </td>
</tr>

What I am trying to do is to disable/enable radiobuttonlist in the same row as the checkbox when you check/uncheck it.

$('tr.child input:checkbox').click(fucntion()
{
     //last part of this selector is incorrect, how to correct it here? 
     var rblist = $(this).closest('tr.child').find(':input:radio');

     if ($(this).is(':checked'))
     { 
        //aslo not sure how to clear selection if any from RadioButtonList here
        rblist.attr('disabled', 'disabled');             

     }
     else
     {

         rblist.removeAttr('disabled');

     }

});

So, those are the problems I have. I am using ASP.NET 3.5. Thanks.

A: 

Try this

$("tr.child td input:checkbox").click(function(){
    var chk = $(this);
    //chk.closest("td").next().find("input:radio").attr("disabled",chk.attr("checked"));
    // to remove checked attribute you can use
    chk.closest("td").next().find("input:radio").attr("checked", false).attr("disabled",chk.attr("checked"));
});
rahul
Thanks for reply. I am just wondering if chk.closest("td") will work since they are in different "td" elements. And how to clear any rb selection before disabling it?
Victor
even though this exact method doesn't work, for one thing, I need to uncheck only when I uncheck checkbox, but gave me a good idea on how to finish my task
Victor