Sunday, December 27, 2009

Re: [jQuery] I would like to get value each time when one of these checkboxes will change status, how can I do that ?

You just want the value of the one that's checked?

$(':checkbox[name=number]').click(function() {
     if ($(this).is(':checked')) alert($(this).val());
});

if you want the total of all checked boxes when one is clicked:
<script type="text/javascript">
    $(document).ready(function() {
        $(':checkbox[name=number]').click(function() {
            var total = 0;
            $(':checkbox[name=number]:checked').each(function() {
                total += parseFloat($(this).val());
            });
            alert(total);
        });
    });
</script>

On Sun, Dec 27, 2009 at 1:08 PM, dziobacz <aaabbbcccdaabb@gmail.com> wrote:
I have:

<input type="checkbox" checked="checked" value="2" name="number"/>
<input type="checkbox" value="7" name="number"/>
<input type="checkbox" value="34" name="number"/>

I would like to get value each time when one of these checkboxes will
change status, how can I do that ? For example when first checkbox
will be unchecked or second will be checked. Could You help me ?





--
Charlie Griefer
http://charlie.griefer.com/

I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.

No comments: