[thelist] Numbers Just Don't Add Up

Lee kowalkowski lee.kowalkowski at googlemail.com
Thu Jan 18 08:18:24 CST 2007


On 18/01/07, Sarah Adams <mr.sanders at geekjock.ca> wrote:
> Or if you want something dead
> simple (but slightly hackish), try something like this:
>
> invoiceTotal = 1* invoiceSubtotal + invoiceShipping + invoiceCOD
>
> The "1*" tells javascript that you're working with numbers, not
> concatenating strings.

You're right, but it's only good for the invoiceSubtotall in your
example, all the other variables will also require a 1 *.

You can use subtraction too, because you can't subtract strings in JavaScript.

invoiceTotal = invoiceSubtotal - -invoiceShipping - -invoiceCOD.

Oh, what fun!

-- 
Lee



More information about the thelist mailing list