Looping through Checkboxes using Javascript
<p>I tried using javascript samples that I found here and other places. The problem is that I am using a Table control working at the server, so the javascript I was using does not recognizes the checkboxes which are server side as well.  I kept getting the same error message over and over. I got 20 rows with 2 colums each, one for the checkbox and one for a statement that the user has to validate by checking the box before they can submit.  The user has to physically check each box.  If any checkbox is not checked, then I would like to sees a popup message saying they must check all boxes, Else I am doing a redirect to another page, of course all this on the button click event.  This all on Visual Studio 2010, using C#, the backend is Sql-server. </p>

<p>Here a sample of the JS I was using.</p>

<pre><code>&lt;SCRIPT TYPE="text/javascript" LANGUAGE=JAVASCRIPT&gt;
function checkCheckBoxes() {
    if (document.frmTest. CheckBox1.checked == false &amp;&amp;
        document.frmTest. CheckBox2.checked == false &amp;&amp;
        document.frmTest. CheckBox3.checked == false &amp;&amp;
document.frmTest. CheckBox4.checked == false &amp;&amp;
document.frmTest. CheckBox19.checked == false &amp;&amp;
document.frmTest. CheckBox5.checked == false &amp;&amp;
document.frmTest. CheckBox6.checked == false &amp;&amp;
document.frmTest. CheckBox7.checked == false &amp;&amp;
document.frmTest. CheckBox8.checked == false &amp;&amp;
document.frmTest. CheckBox9.checked == false &amp;&amp;
document.frmTest. CheckBox10.checked == false &amp;&amp;
document.frmTest. CheckBox11.checked == false &amp;&amp;
document.frmTest. CheckBox12.checked == false &amp;&amp;
document.frmTest. CheckBox13.checked == false &amp;&amp;
document.frmTest. CheckBox14.checked == false &amp;&amp;
document.frmTest. CheckBox15.checked == false &amp;&amp;
document.frmTest. CheckBox16.checked == false &amp;&amp;
document.frmTest. CheckBox17.checked == false &amp;&amp;
document.frmTest. CheckBox18.checked == false &amp;&amp;
document.frmTest. CheckBox20.checked == false &amp;&amp;)
        {
        alert ('You must check all the checkboxes!');
        return false;
        }
    else
        {
        return true;
        }
    }
&lt;/SCRIPT&gt;


then, &lt;form onsubmit="return checkCheckBoxes();" action=""&gt;
&lt;input type="checkbox" name=" CheckBox1" value="1"&gt;
&lt;input type="checkbox" name=" CheckBox2" value="2"&gt;
&lt;input type="checkbox" name=" CheckBox3" value="3"&gt;
&lt;input type="checkbox" name=" CheckBox4" value="4"&gt;
&lt;input type="checkbox" name=" CheckBox19" value="19"&gt;
&lt;input type="checkbox" name=" CheckBox5" value="5"&gt;
&lt;input type="checkbox" name=" CheckBox6" value="6"&gt;
&lt;input type="checkbox" name=" CheckBox7" value="7"&gt;
&lt;input type="checkbox" name=" CheckBox8" value="8&gt;
&lt;input type="checkbox" name=" CheckBox9" value="9"&gt;
&lt;input type="checkbox" name=" CheckBox10" value="10"&gt;
&lt;input type="checkbox" name=" CheckBox11" value="11"&gt;
&lt;input type="checkbox" name=" CheckBox12" value="12"&gt;
&lt;input type="checkbox" name=" CheckBox13" value="13"&gt;
&lt;input type="checkbox" name=" CheckBox14" value="14"&gt;
&lt;input type="checkbox" name=" CheckBox15" value="15"&gt;
&lt;input type="checkbox" name=" CheckBox16" value="16"&gt;
&lt;input type="checkbox" name=" CheckBox17" value="17"&gt;
&lt;input type="checkbox" name=" CheckBox18" value="19"&gt;
&lt;input type="checkbox" name=" CheckBox20" value="20"&gt;
&lt;input type="submit" value="Submit!" /&gt;
&lt;/form&gt;
</code></pre>

<p>But I realized that the Checkboxes cant be server control but jscript controls.   </p>

<p>I am pretty green at coding, so bear with me please.  I greatly appreciate any help I can get. Thanks.</p>
