Skip to content Skip to sidebar Skip to footer

How To Check If RadioButton-Item Is Selected After PageLoad?

My RadioButtonList is created with pure asp.net like this: &l

Solution 1:

When you create:

<asp:RadioButtonList ID="RadioButtonListGutscheinArt" Visible="true" runat="server" ClientIDMode="Static">
     <asp:ListItem ID="ListItemZugAbonnement" ClientIDMode="Static" Value="1" />
     <asp:ListItem ID="ListItemBestellungHalbtax" ClientIDMode="Static" Text="Bestellung Halbtax" Value="2" />
</asp:RadioButtonList>

It actually does this:

<table id="RadioButtonListGutscheinArt" border="0">
    <tbody><tr>
        <td><span clientidmode="Static" id="ListItemZugAbonnement"><input id="RadioButtonListGutscheinArt_0" type="radio" name="ctl00$main$RadioButtonListGutscheinArt" value="1"><label for="RadioButtonListGutscheinArt_0">1</label></span></td>
    </tr><tr>
        <td><span clientidmode="Static" id="ListItemBestellungHalbtax"><input id="RadioButtonListGutscheinArt_1" type="radio" name="ctl00$main$RadioButtonListGutscheinArt" value="2"><label for="RadioButtonListGutscheinArt_1">Bestellung Halbtax</label></span></td>
    </tr>
</tbody></table>

So change your condition to this:

 if ($('#ListItemBestellungHalbtax input').is(":checked")) {
        //do whatever
    }

and it suppose to work.


Post a Comment for "How To Check If RadioButton-Item Is Selected After PageLoad?"