Link to home
Start Free TrialLog in
Avatar of visa1234_12
visa1234_12

asked on

Problem with ColdFusion Shopping Cart

I have a small problem, I have a CF shopping cart and it's working correctly. Now I have to add a donation part to the shopping cart, just in case the buyer feels a little generous and wants to donate more money to the church. I need to have a JavaScript that could update the total amount on the fly (if someone added a donation) the total amount is being calculated correclty with CF. Please Advise.

take a look at www.provisionnetwork.com/newside/onlinestore.cfm

for more info.
Avatar of James Rodgers
James Rodgers
Flag of Canada image

can you clarify how you want the calculation to be done and give the compiled source code from the page(s) in which you want to have the calculation .

Avatar of visa1234_12
visa1234_12

ASKER

When I click on checkout/view cart I have the option of adding/giving more money to the church(www.provisionnetwork.com/newside/onlinestore.cfm). So when I type any amount in the donation text box, I would like the total amount to include the donation amount on the fly (i tried onblur function, and it doesn't work). the total amount currently is being calculated based on the price, quantity, and shipping cost of the product(s). I would like that total to change based on the donation (if any) amount.  
there is no where on that page to enter a value, you need to provide the actual page on w2hich the calculation needs to be performed
after click www.provisionnetwork.com/newside/onlinestore.cfm click on any item and add it to the basket, then click on view cart, and you'll see what i mean.
ASKER CERTIFIED SOLUTION
Avatar of James Rodgers
James Rodgers
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
just a small change in jesters code

<input type="text" name="donation" value="" onBlur="javascript:if(this.value != ''){document.formname.totalsale.value=parseFloat(document.formname.totalsale.value) + parseFloat(this.value);};">

i have used parseFloat because while adding u need to onvert the values into numerical format other wise they will just get concated..

Regards
Hart

hart,

i tried parseFloat on the second value , ie $15.85 and it kept giving me an error, so that's why i went with moving the $ outside the number and used eval in the routine
Jester,

i didn't suggest to write the $ inside the text box...
that remains as u had suggeted..

only thing i asked was while using +, it is better to use parseFloat while adding two numbers...

Regards
Hart
np....

just explaining why i did what i did