Link to home
Start Free TrialLog in
Avatar of leozayas
leozayasFlag for United States of America

asked on

javascript toFixed() problem

Okay this is crazy I have a form that has 3 text inputs
the first takes a quantity, the second the unit price and the third the ext price
i take the quantity and times it by the unit price and make the total the ext price value
and i format the ext price with .toFixed(2) all that is fine
however when i also try to format the unit price to 2 decimals i receive the following error

TypeError: unitprice.toFixed is not a function @ http://www.360-biz.com/www4/printquote/quote-lz-2.html:23

Can anyone please help and tell me why, i will not include the entire html just the pertinent parts



How can it be that the .toFixed() function works the first time but not the second time?
I am baffled.....
ASKER CERTIFIED SOLUTION
Avatar of Gary
Gary
Flag of Ireland 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
replace : var unitpricex = unitprice.toFixed(2);
by : var unitpricex = (unitprice * 1).toFixed(2)
Avatar of leozayas

ASKER

thank you gary :-)