ListBox and CheckBoxList, alert the selected items without the for loop
<p>I got ASP.NET ListBox and CheckBoxList, and onchange I got to alert the selected items which is done in the following code snippet, however I want to get rid of the for loop. Can you please help?</p>

<pre><code>&lt;asp:ListBox ID="ListBox1" runat="server" Width="10%" SelectionMode="Multiple"&gt;
    &lt;asp:ListItem Selected="True" Value="1"&gt;White&lt;/asp:ListItem&gt;
    &lt;asp:ListItem Selected="False" Value="2"&gt;Black&lt;/asp:ListItem&gt;
    &lt;asp:ListItem Value="3"&gt;Red&lt;/asp:ListItem&gt;
    &lt;asp:ListItem Value="4"&gt;Green&lt;/asp:ListItem&gt;
    &lt;asp:ListItem Value="5"&gt;Blue&lt;/asp:ListItem&gt;
&lt;/asp:ListBox&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;asp:CheckBoxList ID="CheckBoxList1" runat="server" Width="10%"&gt;
    &lt;asp:ListItem Selected="True" Value="1"&gt;White&lt;/asp:ListItem&gt;
    &lt;asp:ListItem Selected="False" Value="2"&gt;Black&lt;/asp:ListItem&gt;
    &lt;asp:ListItem Value="3"&gt;Red&lt;/asp:ListItem&gt;
    &lt;asp:ListItem Value="4"&gt;Green&lt;/asp:ListItem&gt;
    &lt;asp:ListItem Value="5"&gt;Blue&lt;/asp:ListItem&gt;
&lt;/asp:CheckBoxList&gt;
</code></pre>

<p>JavaScript</p>

<pre><code>$(document).ready
(
    function () 
    {
        $("#ListBox1").change
        (
            function () 
            {
                for (var i = 0; i &lt; $("#ListBox1 :selected").length; i++) 
                {
                    alert("ListBox Number of Items: " + $("#ListBox1 option").length + "\n"
                    + "ListBox Number of Selected Items: " + $("#ListBox1 :selected").length + "\n"
                    + "ListBox Value: " + $("#ListBox1 :selected")[i].value + "\n"
                    + "ListBox Text: " + $("#ListBox1 :selected")[i].text);
                }
            }
        );
    }
);

$(document).ready
(
    function () 
    {
        $("#CheckBoxList1").change
        (
            function () 
            {
                for (var i = 0; i &lt; $("#CheckBoxList1 :input").length; i++) 
                {
                    if ($("#CheckBoxList1 :input")[i].checked) 
                    {
                        alert("CheckBoxList Number of Items: " + $("#CheckBoxList1 :input").length + "\n"
                            + "CheckBoxList Number of Checked Items: " + $("#CheckBoxList1 input:checked").length + "\n"
                            + "CheckBoxList Value: " + $("#CheckBoxList1 :input")[i].value + "\n"
                            + "CheckBoxList Text: " + $("#CheckBoxList1 label")[i].innerHTML);
                    }
                }
            }
        );
    }
);
</code></pre>

<p>Thanks</p>
