Dynamically checked radio button, based on 'value' attribute, not checking

aero

New Member
Trying to get a form to load pages with the previously checked radios already checked (upon a fresh load).The submissions of that page are held as php variables which I can pass into the javascript, the rest should be simple, but it's not working for me.My code:\[code\]<div class="question"> <label for="sv_213">Question?</label> <input class="radio" type="radio" value="http://stackoverflow.com/questions/12810034/Yes" name="sv_213" />Yes <input class="radio" type="radio" value="http://stackoverflow.com/questions/12810034/No" name="sv_213" />No </div>\[/code\]My javascript:\[code\]$(function() { var $213 = Yes; $("input[name='sv_213'][value="http://stackoverflow.com/questions/12810034/$213"]").attr('checked', true); });?\[/code\]In the above js the\[code\]var $213 = <dynamically generated content>\[/code\]Such that it is set equal to the value of the radio button that was checkedHere is a js fiddle with it not working:http://jsfiddle.net/CW8AC/Many thanks for any help.Incidentally my code is based on this, previously asked question:Set selected radio from radio group with a value
 
Back
Top