kbvishnu
kbvishnu

Reputation: 15650

how can i get the selected asp radio button using jquery?

Here is my aspx code and and i selected the first one by default.How I will get the value in Jquery?

<asp:RadioButtonList runat="server" ID="rbDisType" RepeatDirection="Horizontal" CssClass="styleRadioButton">
<asp:ListItem Text="Sale" Value="True" Selected="True"></asp:ListItem>
<asp:ListItem Text="Damage" Value="False"></asp:ListItem>
</asp:RadioButtonList>

Here is the code its reenders..

 <table id="ctl00_ContentPlaceHolder1_rbDisType" class="styleRadioButton ui-buttonset" border="0">
    <tbody><tr>
        <td><input class="ui-helper-hidden-accessible" id="ctl00_ContentPlaceHolder1_rbDisType_0" name="ctl00$ContentPlaceHolder1$rbDisType" value="True" checked="checked" type="radio"><label aria-disabled="false" role="button" aria-pressed="false" class="ui-button ui-widget ui-state-default ui-button-text-only ui-corner-left" for="ctl00_ContentPlaceHolder1_rbDisType_0"><span class="ui-button-text">Sale</span></label></td>

<td><input class="ui-helper-hidden-accessible" id="ctl00_ContentPlaceHolder1_rbDisType_1" name="ctl00$ContentPlaceHolder1$rbDisType" value="False" type="radio"><label aria-disabled="false" role="button" class="ui-button ui-widget ui-state-default ui-button-text-only ui-corner-right ui-state-active" aria-pressed="true" for="ctl00_ContentPlaceHolder1_rbDisType_1"><span class="ui-button-text">Damage</span></label></td>
    </tr>
</tbody></table>

Upvotes: 0

Views: 2313

Answers (2)

Sukhjeevan
Sukhjeevan

Reputation: 3156

Try this one:

$("input:radio[name$='rbDisType']").click(function(){
      alert($(this).val());
});

Upvotes: 2

Mark
Mark

Reputation: 8291

First look at the code that gets generated i.e. look at the source your browser receives. Then via the ID you can easily navigate there with JQuery and read out the value, should be something like this.

$("#rbDisType").val()

Upvotes: 1

Related Questions