jQuery: select checkbox based on name and value
<p>I have the following HTML:</p>

<pre><code>&lt;form id="test"&gt;
  &lt;input type="radio" value="A" name="C1"/&gt;
  &lt;a href="javascript:selectCheckbox('C1', 'A');"&gt; OPTION-A &lt;/a&gt;

  &lt;input type="radio" value="B" name="C1"/&gt;
  &lt;a href="javascript:selectCheckbox('C1', 'B');"&gt; OPTION-B &lt;/a&gt;

 &lt;input type="radio" value="C" name="C1"/&gt;
  &lt;a href="javascript:selectCheckbox('C1', 'C');"&gt; OPTION-C &lt;/a&gt;

  // several other: C2, C3, ..
&lt;/form&gt;
</code></pre>

<p>And I'm trying to implement <code>selectCheckbox( chkbox, value)</code>, which should:</p>

<ol>
<li>search for all radio's with <code>name = chkbox</code> and set <code>attr('checked') = false</code></li>
<li>search for the radio having <code>name = chkbox AND val() = value</code> and set <code>attr('checked') = true</code></li>
</ol>

<p>I can't figure out, what the right selector is, I tried the following without any luck:</p>

<pre><code>var name = "#" + chkbox + " :checked";
$(name).each(..  // doesn't work

$('#'+chkbox).each( .. // if finds only the first occurence
                       // of i.e. C1, although I would expect 3

$("input[@name='"+chkbox+"']").each( function() { ..
// leaves me with the following error:
// Warning: Expected attribute name or namespace but found '@name'
</code></pre>

<p>Please let me know what I'm doing wrong. Many, many thanks!</p>
