Search code examples
jqueryradiobuttonlist

How can i checked the radiobutton list with value using jquery


i have the radio button list and a textbox with the code below:

   <asp:RadioButtonList ID="RadioButtonList" runat="server" RepeatDirection="Horizontal">
   <asp:ListItem Text="Enabled" Value="1"></asp:ListItem>
   <asp:ListItem Text="Disabled" Value="2"></asp:ListItem>
   </asp:RadioButtonList>

   <asp:TextBox ID="enable" runat="server" value="Enabled"></asp:TextBox>

Now i want the 1st list in the radiobutton list to be seleted/checked but mu jquery code doesnt work. Anyone can help me? I write my jquery code as below :

    if($('#<%= enable.ClientID %>').val()=="Enabled")
        $('#<%= RadioButtonList.ClientID %>').val(1);
   else($('#<%= enable.ClientID %>').val()=="Disabled")
        $('#<%= RadioButtonList.ClientID %>').val(2);

Solution

  • Try this

    if($('#<%= enable.ClientID %>').val()=="Enable")
            $('#<%= roleDropDownList.ClientID %> input[value="1"]').attr('checked','checked');