Getting and setting radio button values with JQuery

I figured I would share this because I found so many inconsistent hits on the internet searching for a solution. I have this dialog that I pop up and want to set the values and then retrieve the values once OK is hit using JQuery.

jquery-radio

The HTML is pretty straight forward:

jquery-html

The code to set the value from my model looks like this:

var $radios = $('input:radio[name=transition]');
$radios.filter('[value=' + model.options.transition +']').attr('checked', true);

The code to retrieve the value looks like this:

model.options.transition = $('input:radio[name=transition]:checked').val();
Short URL: http://bit.ly/Y902Wa

3 thoughts on “Getting and setting radio button values with JQuery

  1. Pingback: Getting and setting check boxes with jQuery | Bob's Blog

  2. Thank you so much for this code – I’ve been searching everywhere for how to replace the value for a radio button set with the value of another radio button set in a 2010 SharePoint form/page I’m coding in SP Designer using JQuery.

Leave a Reply