SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jun 2004
    Location
    england
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile How do you calculate a sum?

    Hey, U guys have helped me before, now Im back for more help :-)

    Ok, here we go.

    I want to add onto my ebay auction a calculation which would show the unit price of a box of 5 electrical sockets.
    So say it is currently on auction at 5.62 and I charge 1.99 Postage & packing thats a total of 7.61 with a unit price of 1.52. Then 1.52 is the figure I want to output and show on screen.

    Please can anyone help me

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    You'd have to do that with Javascript, not HTML. I'll move this thread to the right forum for you so you can get the help you need .

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2004
    Location
    Durham
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you could do it with a quick function. Something like:

    Code:
    function unitPrice(num_units, cur_auction_val, pp) {
        var u_p = (cur_auction_val + pp) / num_units;
        return u_p.toFixed(2);
    }
    then depending on how you want to display it, yours would look something like:

    document.write(unitPrice(5, 5.62, 1.99));


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
  •