title: get selected checkboxlist list items value
body: <pre><code>$(document).ready(function () {
              var values = '';
  
              $('#MainContent_ddl input[type=checkbox]:checked').each(function () {
                  debugger;
                  alert('hi');
                  if (values.length == 0) {
                      values = this.parent().attr('Value');
                  }
                  else {
                      values += "," + $('label[for=' + this.id + ']').html();
                  }
              });
              alert(values);
              return false;
  
          });
  </code></pre>
  
  <p>The above code I am trying to get the currently selected checkboxlist items value which I have defined as follows</p>
  
  <pre><code>&lt;asp:CheckBoxList ID="ddl" runat="server" AutoPostBack="true"
              OnSelectedIndexChanged="ddl_SelectedIndexChanged"
              Style="padding-top: 150px;"&gt;
  
              &lt;asp:ListItem Text="ABC" Value="0"&gt;&lt;/asp:ListItem&gt;
              &lt;asp:ListItem Text="DEF" Value="1"&gt;&lt;/asp:ListItem&gt;
              &lt;asp:ListItem Text="GHI" Value="2"&gt;&lt;/asp:ListItem&gt;
              &lt;asp:ListItem Text="JKL" Value="3"&gt;&lt;/asp:ListItem&gt;
  
          &lt;/asp:CheckBoxList&gt;
  
  &lt;asp:HiddenField ID="hd" runat="server" /&gt;
  </code></pre>
  
  <p>Rendered checkboxlist</p>
  
  <pre><code>&lt;tr&gt;
          &lt;td&gt;&lt;input id="MainContent_ddl_0" type="checkbox" name="ctl00$MainContent$ddl$0" onclick="javascript:setTimeout(&amp;#39;__doPostBack(\&amp;#39;ctl00$MainContent$ddl$0\&amp;#39;,\&amp;#39;\&amp;#39;)&amp;#39;, 0)" value="0" /&gt;&lt;label for="MainContent_ddl_0"&gt;ABC&lt;/label&gt;&lt;/td&gt;
      &lt;/tr&gt;&lt;tr&gt;
          &lt;td&gt;&lt;input id="MainContent_ddl_1" type="checkbox" name="ctl00$MainContent$ddl$1" onclick="javascript:setTimeout(&amp;#39;__doPostBack(\&amp;#39;ctl00$MainContent$ddl$1\&amp;#39;,\&amp;#39;\&amp;#39;)&amp;#39;, 0)" value="1" /&gt;&lt;label for="MainContent_ddl_1"&gt;DEF&lt;/label&gt;&lt;/td&gt;
      &lt;/tr&gt;&lt;tr&gt;
          &lt;td&gt;&lt;input id="MainContent_ddl_2" type="checkbox" name="ctl00$MainContent$ddl$2" onclick="javascript:setTimeout(&amp;#39;__doPostBack(\&amp;#39;ctl00$MainContent$ddl$2\&amp;#39;,\&amp;#39;\&amp;#39;)&amp;#39;, 0)" value="2" /&gt;&lt;label for="MainContent_ddl_2"&gt;GHI&lt;/label&gt;&lt;/td&gt;
      &lt;/tr&gt;&lt;tr&gt;
          &lt;td&gt;&lt;input id="MainContent_ddl_3" type="checkbox" name="ctl00$MainContent$ddl$3" onclick="javascript:setTimeout(&amp;#39;__doPostBack(\&amp;#39;ctl00$MainContent$ddl$3\&amp;#39;,\&amp;#39;\&amp;#39;)&amp;#39;, 0)" value="3" /&gt;&lt;label for="MainContent_ddl_3"&gt;JKL&lt;/label&gt;&lt;/td&gt;
      &lt;/tr&gt;
  </code></pre>
  
  <p>How can I get the currently selected value and store it in a hidden field. Where Am I going wrong.</p>