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.


The HTML is pretty straight forward:


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();

5 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.

  3. Pingback: Blog stats for 2014 and what I learned | Bob's Blog

  4. Pingback: Thank you for a great 2015 and Happy New Year! | Bob's Blog

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.