title: JavaScript & PHP checkbox select all
body: <p>I have problem with select checkbox with the JavaScript in the HTML file. I know how to do this but in my form all checkbox have <code>name='chk[]'</code>:</p>
  
  <pre><code>&lt;form name="forms" action='index.php' method='post'&gt;
      &lt;input type='checkbox' name='chk[]' value='value1'&gt; ANY VALUE 1 &lt;/br&gt;
      &lt;input type='checkbox' name='chk[]' value='value2'&gt; ANY VALUE 2 &lt;/br&gt;
      &lt;input type='checkbox' name='chk[]' value='value3'&gt; ANY VALUE 3 &lt;/br&gt;
      &lt;input type='checkbox' name='chk[]' value='value4'&gt; ANY VALUE 4 &lt;/br&gt;
      &lt;input type='submit' name='submit' value='Get Value'&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>In my PHP file I use select checkbox:</p>
  
  <pre><code>&lt;?php
      $s = "";
      $value = $_POST['chk'];
  
      $s .= join(", ", $value);
  
      echo $s;
  </code></pre>
  
  <p>But how can I create a function in JavaScript which checks the field.
  I've also tried <a href="https://stackoverflow.com/questions/7259335/select-all-checkbox">this</a></p>