title: Getting All HTML Checkboxes (Array) Checked with Javascript (and PHP)
body: <p>I've been searching for this for a couple hours with no luck. This seems like it should be fairly easy but I am obviously overlooking something.</p>
  
  <p>I have a table, with each row displaying information in each cell. At the end of each of the rows, there is an additional cell with a checkbox in it. The checkbox is an array, and each checkbox value is an imploded array via PHP. See below:</p>
  
  <pre><code>HTML/PHP
  --------
  (...some html code...)
  &lt;form method="post" action="the-next-page.php"&gt;
    &lt;table&gt;
      &lt;tr&gt;
      &lt;?php
      (...some php SQL query code...)
      while ($row = oci_fetch_array($result)) {
      ?&gt;
        &lt;td&gt;&lt;input type="text"&gt;Name&lt;/td&gt;
        &lt;td&gt;&lt;input type="text"&gt;City&lt;/td&gt;
        &lt;td&gt;&lt;input type="checkbox" name="checkGroup[]" value="&lt;?php implode(":",$someArrayvariable) ?&gt;"&gt;&lt;/td&gt;
      &lt;?php
      }
      ?&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;input type="submit" value="submit"&gt;&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/table&gt;
  &lt;/form&gt;
  ....
  &lt;/html&gt;
  </code></pre>
  
  <p>Passing the imploded values to the next page works fine. No problem there.</p>
  
  <p>I have been trying to create a javascript function to check all of the boxes that are in this form, or under the checkbox group's name, or whatever I can do to check them all with the click of a button. I've tried variations of the following with no success:</p>
  
  <pre><code>HTML (On the top of the same script as above)
  ----
  &lt;button name="checkAll" onclick="checkAll()"&gt;Check All&lt;/button&gt;
  
  Javascript (On the bottom of the same script as above)
  ----
  &lt;script type="text/javascript"&gt;
  function checkAll() {
      var checks = document.getElementByName("checkGroup");
      for (var i=0; i &lt; checks.length; i++) {
          checks[i].checked = true;
      }
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>I can't figure out what I'm doing wrong. I know that a variation of this question has been asked before many times, but I don't seem to be getting any results. I'm guessing because my checkboxes name is an array (checkGroup[] ???).</p>
  
  <p>When I click the button to check all of the checkboxes in the form, nothing happens.</p>
  
  <p>Any ideas? Thanks in advance.</p>
  
  <p>-Anthony</p>