Javascript Addition Conumdrum
Posted: Fri Aug 29, 2008 9:41 am
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: For example
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
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);Code: Select all
amount = amount + 3.00;Code: Select all
amount = parseFloat(amount) + 3.00;Thanks for any help