title: HTML Control Array in JavaScript - Checkbox array of 1 returns zero length
body: <p>I'm using a control array of checkboxes to capture a multiple selection</p>
  
  <p>The following code, with two checkboxes, works well and returns a value of <strong>2</strong> as expected (or however many are there).  </p>
  
  <p>However if there is only one checkbox item in the array, it returns a length of <strong>0 (zero)</strong>.... why is this? Shouldn't it return a length of 1?</p>
  
  <p>I have tried this in Internet Explorer and Chrome with the same results.  As a work around I am having to include a hidden bogus checkbox in the array to make sure there is always two or more items when I run the code.</p>
  
  <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;&lt;/title&gt;
      &lt;script language="javascript" type="text/javascript"&gt;
          function categoryOnClick() {
              var selectedRows = document.searchForm.elements['categorySelect[]'];
              alert(selectedRows.length);
          }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form name="searchForm" action=""&gt;
          &lt;input type="checkbox" name="categorySelect[]" id="1" onclick="categoryOnClick();"/&gt;
          &lt;input type="checkbox" name="categorySelect[]" id="2" onclick="categoryOnClick();"/&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Code that returns 0 (zero) length...</p>
  
  <pre><code>&lt;form name="searchForm" action=""&gt;
       &lt;input type="checkbox" name="categorySelect[]" id="1" onclick="categoryOnClick();"/&gt;
  &lt;/form&gt;
  </code></pre>