Javascript Addition Conumdrum

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
LiveFree
Forum Contributor
Posts: 258
Joined: Tue Dec 06, 2005 5:34 pm
Location: W-Town

Javascript Addition Conumdrum

Post 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
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: Javascript Addition Conumdrum

Post 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?
Post Reply