SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Mar 2002
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question floating point numers & Decimal Places

    any body know how to force javascript to display a number with 2 decimal places (ie, 10.50 instead of 10.5) so that it represents currency better?

    dave

  2. #2
    @russellg RussellG's Avatar
    Join Date
    Jun 2000
    Location
    Gold Coast, Queensland
    Posts
    449
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I hope this link helps you.
    russell.cz.cc - coming soon (I promise!)

  3. #3
    SitePoint Member
    Join Date
    Mar 2002
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i still cant get it to work.

    parseDec and parseMoney are not recognised as and causes errors

    do you have to use the archive and source attributes in the script tag to call a .js file.

    if so, how?

  4. #4
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Moved to a more appropriate forum

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  5. #5
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    go here

    http://javascript.internet.com/forms...cy-format.html
    http://javascriptkit.com/script/script2/twodec.shtml

    PHP Code:
    function format(str) {
    index str.indexOf(".");
    if (
    index 0str str ".00";
    else {
    str str.substring(0index 3);
    if (
    str.length < (index 3)) str += "0";
    }
    return 
    str;



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
  •