Check all radio controls with a specific substring on an ASP.NET form
<p>I'm working on a .NET-powered questionnaire which contains several repeater controls, each row of which contains three radiobuttons. I'm trying to write a simple Javascript function to check all the controls on the page which contain the word "chkGreen" in the control name/id.</p>

<p>The page looks something like this:</p>

<pre><code>Repeater 1
Description 1           ( ) Green ( ) Yellow ( ) Red
Description 2           ( ) Green ( ) Yellow ( ) Red
Description 3           ( ) Green ( ) Yellow ( ) Red

Repeater 2
Description 1           ( ) Green ( ) Yellow ( ) Red
Description 2           ( ) Green ( ) Yellow ( ) Red
Description 3           ( ) Green ( ) Yellow ( ) Red
</code></pre>

<p>Here's the function so far:</p>

<pre><code>   for (i = 0; i &lt; document.Form1.elements.length; i++) {
      var _control = document.Form1.elements[i].id
      if (_control.indexOf("chkGreen") &gt; 0) {
         eval(_control.checked = true);
      }
   }
</code></pre>

<p>This function does not work. When I add a document.write or alert() to the statement, it properly fires, so the logic is apparently working, it's just the actual radiobutton check code is not working.</p>

<p>Any thoughts?</p>
