Javascript Calculator

I have this calculator: http://johnbarban.com/calculator/adonis.html the problem is that I need the results to only show 2 decimal places. Could someone show me what code I would use to make this happen?

Thanks
turtleman2009Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Brad HoweDevOps ManagerCommented:
Can you use the function Number.toFixed(x)

It formats any number for "x" number of trailing decimals. The number is rounded up, and "0"s are used after the decimal point if needed to create the desired decimal length.

eg:
      idealwaist.toFixed(2)

Cheers,
Hades666
0
turtleman2009Author Commented:
I just tried your solution and I could not get it to work, this is how I applied it:

document.getElementById('adonisidealwaist').innerHTML = idealwaist.toFixed(2);

Did I do it incorrectly?
0
Brad HoweDevOps ManagerCommented:
Sorry correction. Just looked at your could and you are using floats.

var water = weight * 0.025;

//Add the following formatters      

idealwaist = parseFloat(idealwaist).toFixed(2);
idealshoulders = parseFloat(idealshoulders).toFixed(2);
hips = parseFloat(hips).toFixed(2);
maxloss = parseFloat(maxloss).toFixed(2);
water = parseFloat(water).toFixed(2);


Cheers,
Hades666
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
turtleman2009Author Commented:
Hmm,

I am still having trouble with this.

When I use this code it completely stops calculating.

Any thoughts?
0
turtleman2009Author Commented:
It worked after all, it was just on my local machine that it wasn't working
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.