title: CheckBoxList Items using JavaScript
body: <p>I have a checkoxlist with a couple of items and an all option.  The user can select all and I want this to check off all the options and if they uncheck all it will uncheck all options.</p>
  
  <p>I have accomplished this with the following code.</p>
  
  <pre><code>&lt;script language="javascript" type="text/javascript"&gt;
      function CheckBoxListSelect(cbControl) //, state)
      {
          var chkBoxList = document.getElementById(cbControl);
          var chkBoxCount= chkBoxList.getElementsByTagName("input");
  
          alert(chkBoxCount[0].checked);
  
          for(var i=0;i&lt;chkBoxCount.length;i++)
          {   
              chkBoxCount[i].checked = chkBoxCount[0].checked //state;
          }
  
          return false; 
      }
  &lt;/script&gt;
  
  cblAffiliation.Attributes.Add("onclick", "javascript: CheckBoxListSelect ('" &amp; cblAffiliation.ClientID &amp; "');")
  </code></pre>
  
  <p>The issue is that if I select any  of the boxes it loops through and then sets them to whatever the all option is.  I am having trouble figuring out the best way to get around this.</p>
  
  <p>I want to avoid using a checkbox next to the checkboxlist, then I have to make that line up with the checkboxlist.</p>