Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to keep trailing zeros and Math.round?

    Am filling in for someone and don't know Javascript -- have looked for hours on boards but can only find an answer for a single variable.

    Issue: 2 decimal points showing everywhere except when the output has .00 at the end. How do I get those zeros to show? Here is the math code:

    Code:
    for (var p in output_data) {
    		 $('#'+p).html(Math.round(output_data[p]*100)/100);
    All of the source code is viewable here:

    http://www.interactivesystems.biz/is/tvupload.php

    Folder is protected:
    user = is
    pass = michael11

    Please see the Sony Projector section - the first item subtotal should be 3875.00 and comes out as just 3875 when you choose a Quantity of 1.

    I am really stuck and would be very, very appreciate of any assistance. Thanks so much.

  • #2
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,373
    Thanks
    11
    Thanked 592 Times in 572 Posts
    Math.round(output_data[p]*100)/100
    should be:
    (Math.round(output_data[p]*100)/100).toFixed(2);
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.6, IE11:9.1, IE9:3.1, IE10:3.0, FF:17.2, CH:46, SF:11.4, NON-MOUSE:38%

  • #3
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks so much for the response, but using that code turns all tax and subtotal fields to 0?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •