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:RadioButtonListID="RadioButtonListGutscheinArt"Visible="true"runat="server"ClientIDMode="Static"><asp:ListItemID="ListItemZugAbonnement"ClientIDMode="Static"Value="1" /><asp:ListItemID="ListItemBestellungHalbtax"ClientIDMode="Static"Text="Bestellung Halbtax"Value="2" /></asp:RadioButtonList>

It actually does this:

<tableid="RadioButtonListGutscheinArt"border="0"><tbody><tr><td><spanclientidmode="Static"id="ListItemZugAbonnement"><inputid="RadioButtonListGutscheinArt_0"type="radio"name="ctl00$main$RadioButtonListGutscheinArt"value="1"><labelfor="RadioButtonListGutscheinArt_0">1</label></span></td></tr><tr><td><spanclientidmode="Static"id="ListItemBestellungHalbtax"><inputid="RadioButtonListGutscheinArt_1"type="radio"name="ctl00$main$RadioButtonListGutscheinArt"value="2"><labelfor="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?"