Yasserzaid’s Weblog

March 20, 2009

Get Selected Value of RadioButton using Javascript

Filed under: Javascript — yasserzaid @ 11:59 am

Hi

try this example:-

<asp:RadioButtonList ID="RadioButtonList1" runat="server">
        <asp:ListItem Value="1"></asp:ListItem>
        <asp:ListItem Value="2"></asp:ListItem>
        <asp:ListItem Value="3"></asp:ListItem>
        <asp:ListItem Value="4"></asp:ListItem>
</asp:RadioButtonList>[code]

and the javascript function

[code]function getCheckedRadio()
{
  var radioButtons = document.getElementsByName("RadioButtonList1");
  for (var x = 0; x < radioButtons.length; x ++) {
    if (radioButtons[x].checked) {
      alert("You checked " + radioButtons[x].id + " which has the value " + radioButtons[x].value);
    }
  }
}

Good Luck

No Comments Yet »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.