[thelist] Numbers Just Don't Add Up
Bob Blackman
bob at kaboomconsulting.com
Wed Jan 17 11:48:55 CST 2007
I'm experiencing a problem that seems so simple yet I need your help...
In javascript I initialize some variables:
var invoiceOrderTotal = 0;
var invoiceDiscount = 0;
var invoiceSubtotal = 0;
var invoiceShipping = 10;
var invoiceTotal = 10;
I then modify these values:
invoiceOrderTotal += order[rowNum].pulledQty * order[rowNum].salePrice;
invoiceSubtotal = invoiceOrderTotal - invoiceDiscount;
invoiceTotal = invoiceSubtotal + invoiceShipping;
The above works with no problem. But later when I prepare an invoice,
my values are concatenated rather than summed. Thus say
invoiceSubtotal = 100.00
invoiceShipping = 10.00
invoiceCOD = 0.00
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.
Can any of you please help?
Thanks,
Bob
More information about the thelist
mailing list