How to update value of a radio using Jquery
<p>I have this HTML code for radios:</p>

<pre><code>&lt;input type='radio' name='a_27' value='Yes' id='a_27_0' /&gt;

&lt;input type='radio' name='a_27' value='No' id='a_27_1' /&gt;
</code></pre>

<p>I'm trying to set the selected value of the radio using this code:</p>

<pre><code>var field="a_" + this.id;
$('[name="' + field + '"]').val(this.value);
console.log("name is " + field + ", val is " + this.value);
</code></pre>

<p>However it doesn't work, nothing happens when this runs. Here's the output from Firebug's console which occurs after the 3rd line:</p>

<blockquote>
  <p>name is a_27, val is Yes</p>
</blockquote>

<p>Any ideas?</p>

<p>I would prefer a method which would also work on <code>&lt;select&gt;s</code>, so I wouldn't need to write additional/seperate code for radios and selects.</p>

<p>Edit: A weird problem I've noticed that although my html code gives a different value (yes/no), in firebug it shows both radios as having the value 'yes'. If I select no and click save, the javascript function still receives 'yes' instead of no. Am I doing something wrong?</p>

<p>Edit 2: The full function:</p>

<pre><code>function processMultiOptAnswers()
{
    $.each(multiOpts,function()
        {
            var field="a_" + this.id;
            console.log("name is " + field + ", val is " + this.value);

            $('[name="' + field + '"]').val(this.value);
        }
    );
}
</code></pre>
