How to find the radio button selected in an ASP.NET form using jQuery

If you use asp.net RadioButtons you might have an issue when trying to find out which radio button is selected when it comes to jQuery. There are a lot of examples out there for people who use RadioButtonLists but for most people it might not be practical to display radio buttons like this.

If you use regular asp.net radio buttons then by using the following sample below you should see how to target the correct group of radio buttons and find out which has been selected.

HTML Code:

  • creditcard
  • cash
  • invoice

Javascript Code:

 

$("#PayNowButton").click(function (evt) {
        evt.preventDefault();
            var selectedPayment = $("#PaymentSection input[type='radio']:checked").val();
            alert('You selected: '+selectedPayment);
    });


Share this post


blog comments powered by Disqus

Updates

Follow me online at TwitterFacebook or Flickr. If you want to get in touch with me try emailing me.

Latest Tweets