[thelist] Numbers Just Don't Add Up

Lee kowalkowski lee.kowalkowski at googlemail.com
Wed Jan 17 12:12:09 CST 2007


On 17/01/07, Bob Blackman <bob at kaboomconsulting.com> wrote:
>
> I get the evaluation of
>
> invoiceTotal = invoiceSubtotal + invoiceShipping + invoiceCOD
>
> Displays 10010.
>
> I have been looking for a method to cast the values as numbers but
> haven't come across anything.

It doesn't matter how you initialise a variable in JS, a variable will
be the type of it's last assignment.  Referencing formField.value
brings strings into the mix.

var number = new Number(string);

Is the best way to cast.

-- 
Lee



More information about the thelist mailing list