Question

I am currently working on a project that needs to forward an email to every selected customer inside a repeater. I am working with a checkbox that I assign the email-address as value inside an asp repeater.

                <ItemTemplate>
                    <div class="odd">
                     <asp:label ID="lblT" runat="server" style="visibility:collapse; margin-left:9999px;" Text='<%# Eval("exposantID") %>'></asp:label>

                     <input runat="server" type="checkbox" class="chkExpo"  id="chkExpo" value='<%# Eval("exposantMail") %>'  />

Now I'm using jQuery :checked statement to get every checked checkbox inside the repeater.

    var n;
    function countChecked() {
         n = $("input:checked").length;

     }
     $(":checkbox").click(countChecked);

    countChecked();



    $("input").click(function () {

        for (var i = 0; i < n; i++) {
            alert($("input:checked").val());
        }



    });

The problem is I can only get the first checked value...I tried working with an index value but that didn't solve the problem. Does anyone have an idea how to get the value for each checkbox that is checked using this method?

Thanks,

Arnoud

Was it helpful?

Solution

$("input[type='checkbox']").click(function () {
    $("input[type='checkbox']:checked").each(function(){
        alert($(this).val());
    });
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top