Use jquery to just set radio buttons that are currently a certain value
<p>I've an HTML page with a number of tables, one for each user in the database.
The first four columns of each table are radio buttons, with the values: G, A, X and blank respectively.</p>

<p>What I want to do is set the radio button to e.g. 'A' for all rows that are currently blank.</p>

<p>Here was where I started:</p>

<pre><code>var st='A';
$('#user123 input').val([st]);
</code></pre>

<p>This works, but it also sets to A the rows that were already 'G' or 'X'.</p>

<p>Here is what I've tried that didn't work:</p>

<pre><code>$('#user123 input[value=]').siblings().val([st]);
</code></pre>

<p>(nothing gets set)</p>

<pre><code>$('#user123 input[value=]').parent().children().val([st]);
</code></pre>

<p>(the blank radio button gets cleared, none get set)</p>

<pre><code>$('#user123 input[value=]').val([st]);
</code></pre>

<p>(the blank radio button gets cleared, none get set)</p>

<pre><code>$('#user123 input').not('[value=G]').val([st]);
</code></pre>

<p>(planning to add exceptions for A and X later, but it already doesn't work - all radio buttons get set to 'A', not just the blank ones)</p>

<p>I'm really close aren't I? But I just cannot find the magic incantation I need!</p>

<p>Here is a cut-down version of the table HTML:</p>

<pre><code>&lt;table id="user123"&gt;
&lt;tr&gt;
&lt;td&gt;&lt;input name="r520" value="G" type="radio"&gt;&lt;/td&gt;
&lt;td&gt;&lt;input name="r520" value="A" type="radio"&gt;&lt;/td&gt;
&lt;td&gt;&lt;input name="r520" value="X" type="radio"&gt;&lt;/td&gt;
&lt;td&gt;&lt;input name="r520" value="" type="radio" checked&gt;&lt;/td&gt;
&lt;td&gt;2011-06-01&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;input name="r767" value="G" type="radio"&gt;&lt;/td&gt;
&lt;td&gt;&lt;input name="r767" value="A" type="radio"&gt;&lt;/td&gt;
&lt;td&gt;&lt;input name="r767" value="X" type="radio"&gt;&lt;/td&gt;
&lt;td&gt;&lt;input name="r767" value="" type="radio" checked&gt;&lt;/td&gt;
&lt;td&gt;2011-06-03&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
</code></pre>

<p><strong>UPDATE</strong>
Thanks for replies; here is the solution I went with (mainly inspired by michelpm's):</p>

<pre><code>var st='A';
$('#user123 tr').each(function() {
    if($("input:radio[value=]:checked",this).length){
        $("input:radio[value="+st+"]",this).attr("checked",true);  
        }
    });
</code></pre>
