Results 1 to 2 of 2

Thread: How to display trailing zero's after multiplication

  1. #1
    Join Date
    Feb 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to display trailing zero's after multiplication

    I have javascript function which calculates the product of two numbers.

    Code:
    function fnCalculate()
    {
    
     var lat1=price * num;
    
    }
    Here for eg if price is 19.50 and num is 1 then o/p should be 19.50 and not 19.5 as its resturning now.

    Also if price is 15.00 and num is 1 then o/p should be 15.00 and no just 15.

    Is it possible ... someone please help
    Last edited by jscheuer1; 02-08-2012 at 08:15 PM. Reason: Format

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    See:

    http://www.w3schools.com/jsref/jsref_tofixed.asp

    Like:

    Code:
    var lat1 = (price * num).toFixed(2);
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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