Results 1 to 5 of 5

Thread: Unhappy Please help - calc percent in javascript

  1. #1
    Join Date
    Jan 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Unhappy Please help - calc percent in javascript

    Hi ,

    Please help me with this problem :

    I whoul like to change the precent from *1.17 (17%) to calc of precent like this :

    3% + 5% + 5$ = Result

    For example :

    The resault is 10$ - i want to write in code instead *1.17 :

    10$ +3%(0.3$) + 0.5% (0.51$) + 5$ = 15.81$

    How i change this line to this calc

    if(results[i].getSite()=='Xxx'&&XPrice==0)
    {
    XPrice =(results[i].getPrice() *1.17);
    }
    }


    Please help me with this is very iportant to me

    Thank you so much !
    Last edited by traq; 01-03-2014 at 07:38 AM.

  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

    *1.17

    is 117 percent of.

    The % symbol in javascript means modulo (remainder after division by a number). If you don't want a modulo, don't use it. For percent, multiply by the decimal.
    Last edited by jscheuer1; 01-03-2014 at 05:28 PM. Reason: spelling
    - John
    ________________________

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

  3. #3
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    This question is extremely unclear. At first, I was preparing myself to look up some Java syntax. Before anyone can begin answering this question, you need to restate it in a way that makes it comprehensible and valid (grammatically and logically). Provide us with a few input/output fields so we know what you're talking about and specify exactly what you want.

    @John Maybe he's trying to add 17%?

  4. #4
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by Nile View Post
    @John Maybe he's trying to add 17%?
    I think John hit it: the code works as desired but the OP doesn't like the syntax (he wants to specify the percentages with a % sign, which, as John points out, does something else entirely).

  5. #5
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    OP:

    Code:
    price * 1.08 + 5; //Multiply the code by 100% + 5% + 3% (1.08), then add 5

Similar Threads

  1. Floating Menu - Width in percent?
    By Chris P. Bacon in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 05-13-2008, 03:30 PM
  2. Calc Elapsed Time between 2 form fields
    By kevin_dalby in forum JavaScript
    Replies: 2
    Last Post: 11-09-2007, 06:51 PM
  3. background image set as a percent?
    By mdcloud in forum CSS
    Replies: 4
    Last Post: 06-30-2007, 01:55 AM
  4. Javascript calc help
    By Aragorn in forum JavaScript
    Replies: 5
    Last Post: 01-28-2007, 09:38 PM
  5. Need help with table/calc
    By jmoney98 in forum JavaScript
    Replies: 2
    Last Post: 07-26-2005, 09:38 PM

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
  •