• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 272
  • Last Modified:

jquery formating decimal places problem

Hi.
I'm using variables of prices and when using one on its own the formatting (decimal places) is fine like when I set the variable: var unitcore = (1*(unitcost)).toFixed(2);

but when I try and do a calculation I just can't get the formating back: trying this doesn't work: $("#tblunit").html(unitcore - disc).toFixed(2); and without the Fixed (2) doesn't work either.

Any ideas please clever people?

Thanks
0
swordfishsoup
Asked:
swordfishsoup
1 Solution
 
Steve KrileCommented:
In my opinion, it's "better" to do all your calculations without regard to formatting, then, change the result as you like.

So, this has always been a safer approach for me:

var result = unitcore - disc;
result = result.toFixed(2);

$("#tblunit").html(result);
0
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.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now