Page 1 of 1

Javascript Addition Conumdrum

Posted: Fri Aug 29, 2008 9:41 am
by LiveFree
Good morning,

I've been writing a very small PayPal-shopping cart interface for a photography business and I've run into an issue with calculating the total item amount.

The way it works is that each photo has a "base price" for the smallest size (3x5), for each incremental size after that (4x6, 5x7, etc), the price raises $1. The way the script is written, a JS function takes the value of the 'amount' hidden input (the base outputted by a PHP script), reads the selected size, and adds the appropriate amount of $ to the final price (changes the value of the hidden input)

The problem is that, the two numbers dont seem to want to add up

I've tried:

Code: Select all

amount = parseFloat(amount) + parseFloat(3.00);
For example

Code: Select all

amount = amount + 3.00;

Code: Select all

amount = parseFloat(amount) + 3.00;
None of those work. FYI - The 'amount' variable represents the value of the hidden input, which originally contains the base price.

Thanks for any help

Re: Javascript Addition Conumdrum

Posted: Sun Aug 31, 2008 4:26 pm
by JAB Creations
Echo is your friend in PHP just as alert is your friend in JavaScript. Alert what you're trying get a sum with 3.00. Is amount even an integer or is it null for example?