SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Oct 2002
    Posts
    229
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    replacing . with nothing

    I am having trouble replacing a fullstop with "".

    I've tried
    commission=commission.replace(".","");
    but i get the javascript error :
    message object does not support this property or method
    Is anyone able to advise me on this....

    Thanks
    Eternity

  2. #2
    SitePoint Addict
    Join Date
    May 2000
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  3. #3
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    .replace() is a method of String - so 'commission' is presumably - at least in some specific application of that line of code - not a string. You'll need to post more of your code, including the source of that value.
    ::: certified wild guess :::

  4. #4
    SitePoint Addict
    Join Date
    Oct 2002
    Posts
    229
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am creating a calculator in a form and want to add a commission value to the total.

    To add the commission value to the total I have used the following maths
    total * (1.0 + commission)
    so a commission of 3% is 1.03

    However then someone adds a decimal to their comission ie 3.2, the javascript gets confused and gives NaN as it is trying to multipy the total by 1.03.2.

    This is why I want to remove the fullstop from the original commission value...
    Eternity

  5. #5
    SitePoint Addict
    Join Date
    May 2000
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Couldn't you divide commission by 100 giving you .032 and then add 1.0 giving 1.032?

  6. #6
    SitePoint Addict
    Join Date
    Oct 2002
    Posts
    229
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ah yes - how simple was that!

    Thanks everyone
    Eternity


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
  •