It's because inside your .each statement you are re-selecting *all*
checked boxes again, so

$('input[name=additionals]:checked').each(function() {
        amountdue += parseFloat( $(this).val() );
});

Check out the documentation of ".each()", where it will explain that
inside the loop, "this" is the current DOM item being enumerated by
the each()


On Jul 6, 1:16 am, tkrn <psta...@etechrongroup.com> wrote:
> This is what i have. It does not correctly add two values when two
> checkboxes are checked. It should add up to 160 but it adds up to 20
> instead! any ideas?
>
> Thanks
> Patrick
>
> <label><input type="checkbox" name="additionals"
> id="NutsandBoltsPreconference"  value="150" /> Nuts and Bolts
> Preconference</label><br/>
> <label><input type="checkbox" name="additionals" id="TestAdd"
> value="10" /> TestAdd</label>
>
> $('input[name=additionals]:checked').each(function() {
>         amountdue += parseFloat( $('input[name=additionals]:checked').val
> () );
>
> });

Reply via email to