Tuesday, July 10, 2012

Asp.Net jQuery Get Value and Checked status of all RadioButtons in the page


In this post Asp.Net jQuery Get Value and Checked status of all RadioButtons in the page, we shall see on how to get the values and checked status of all the radio buttons in a page using jQuery.
We can use the following script to get the radio button values and status in a Page


$("input[type=radio]").each(function() {
  alert($('label[for=' + this.id + ']').html() + ' => ' +
  $(this).is(':checked'));
});

On click of a button uses the following script.

// Loop through - Get RadioButton Label/Values
$('#cmdGetValues').click(function(event) {
    event.preventDefault();
    $("input[type=radio]").each(function() {
        alert($('label[for=' + this.id + ']').html() + ' => ' + $(this).is(':checked'));
    });
});

To see a full example using jQuery and Radio Buttons refer to the post Asp.Net jQuery Radio Button Tutorial

Search Flipkart Products:
Flipkart.com

No comments: