How to save the selected value of checkboxlist in array?
<p>I want to save the values of checkbox in an array using javascript or jquery.
My checkboxlist is inside the datalist. Whenever the user select an item, I want to add the value of that selected item to a array.</p>

<pre><code>ASPX :

 &lt;asp:DataList ID="dl_Groups_1" RepeatColumns="1"  runat="server" OnItemDataBound="dl_Groups_1_ItemDataBound" RepeatDirection="vertical" ShowFooter="False" ShowHeader="False"&gt;
        &lt;ItemTemplate&gt;
           &lt;asp:CheckBox Font-Bold="true" runat="server" ID="chk_Group_1" Text='&lt;%# Eval("category_type") %&gt;' Value='&lt;%# Eval("service_type_category_id") %&gt;' onclick="OnGroupClick" /&gt;
            &lt;asp:CheckBoxList  CssClass="line" runat="server" ID="chkServiceType_1" DataValueField="ServiceTypeID" DataTextField="Name" EnableViewState="true"&gt;
            &lt;/asp:CheckBoxList&gt; 
            &lt;br /&gt;
        &lt;/ItemTemplate&gt;
    &lt;/asp:DataList&gt;
</code></pre>

<p>I tried the below to, get the items that are slected, but i am struck up here...</p>

<pre><code>function test() {
    $(":checkbox").each(function () {
        if (this.checked) {
            alert(this);
        }
    });
}
</code></pre>

<p>When i do this, i get alert message as "ON" and not the value. And where do i call the javascript to keep the array updated on selecting and un selecting the items in checkboxlist ? </p>
