title: Can not get value of checked items in checkboxlist via javascript
body: <p>in my application I have a checkbox list. Listed below is the html for the checkbox list, as well as the vb code that bind it on load of the page it is located on.</p>
  
  <pre><code>&lt;asp:CheckBoxList Runat="server" id="chklistTeams" RepeatColumns="7" RepeatDirection="Horizontal"
                          CellPadding="4" Font-Size="7pt"&gt;&lt;/asp:CheckBoxList&gt;
  </code></pre>
  
  <p>Below is the VB to bind the checkboxlist</p>
  
  <pre><code>myCmd.CommandText = "Select id, title from teams"
  Dim DS As SqlDataReader
  DS = myCmd.ExecuteReader
  chklistTeams.DataValueField = "id"
  chklistTeams.DataTextField = "title"
  chklistTeams.DataSource = DS
  chklistTeams.DataBind()
  DS.Close()
  </code></pre>
  
  <p>When a save button is hit a javascript function is called. Here is the part of the function that is called that should get us the value of the items.</p>
  
  <pre><code>var checkList = document.getElementById('chklistTeams');
  var checkBoxList = checkList.getElementsByTagName("input");
  var checkBoxSelectedItems = new Array();
  
  for (var i = 0; i &lt; checkBoxList.length; i++) {
      if (checkBoxList[i].checked) {
          checkBoxSelectedItems.push(checkBoxList[i].value);
          alert('checked - checkBoxList[i]: ' + checkBoxList[i].value)
      }
  }
  </code></pre>
  
  <p>All the values getting stored to the array (tested with the alert) - are coming back with the value "on" - so I then checked the html of the checkboxes in this list, here was the result for one of the checkboxes</p>
  
  <pre><code>&lt;input name="chklistTeams:21" id="chklistTeams_21" type="checkbox" value="on"/&gt;
  </code></pre>
  
  <p>I am sure the values are being binded correctly to the list - because in the old way of getting their values, you get the correct integer value for the item - listed below is that VB code that used to handle this (and returned a string of integers, depending on how many boxes were checked - did not return a list of the value "on"). I need to be able to get this via javascript for another modification we are making on this page where we must now save using PageMethods and can't use this on the back end with a public shared function</p>
  
  <p>VB code that will get the right values of checked items in checkboxlist</p>
  
  <pre><code>    For Each li In chklistTeams.Items
          If li.Selected = True Then
              strTeamList = strTeamList &amp; li.Value &amp; ","
              bolTeamSelected = True
          End If
      Next
      If bolTeamSelected = True Then
          strTeamList = strTeamList.Substring(0, strTeamList.Length - 1)
      End If
  </code></pre>
  
  <p>Can anyone see why the javascript way to get the values is giving me "on" instead of the integer value like the VB way does? Thanks again for your help. Again - this must be done in JS - can't use the VB code behind way due to the function being public and shared. Thanks.</p>