SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Zealot eStudio's Avatar
    Join Date
    Dec 2001
    Location
    NE Texas
    Posts
    153
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JS Newbie - Form Fields

    I'm completely new to JS - other than simple mouseovers and such, but I would like to learn if anyone can point me in the right direction to do the following:

    2 form fields - cost and retail

    once the cost is entered in the first field (cost), and the next field (retail) is selected, I would like to display the cost+35% markup [ie: SUM(cost+(cost*35%))] ???

    I know it is probably easy and I would rather someone just point me in the right direction for now, then if I can't figure it out for myself maybe more help.

    TIA,
    Donna

  2. #2
    morphine for a wooden leg randem's Avatar
    Join Date
    Jun 2002
    Location
    .chicago.il.us
    Posts
    957
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ----Adopt-a-Sig----
    Your message here!

  3. #3
    SitePoint Zealot eStudio's Avatar
    Join Date
    Dec 2001
    Location
    NE Texas
    Posts
    153
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks randem!

    so far the webliminal link has been most helpful for me because of the examples




    Donna

  4. #4
    SitePoint Zealot eStudio's Avatar
    Join Date
    Dec 2001
    Location
    NE Texas
    Posts
    153
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, I've got a JS working like I need, enter cost, it calculates profit and retail - but here's another question:

    When it calculates the retail, is there a way to force the price to always end with .95 or .99 ?

    For example:

    cost: 10.00
    profit: 3.50
    retail: 13.50 <--- make this auto to 13.95

    Just point me in the right direction - I'm on a roll ( I think ) - I've had my supply of Dr Pepper this A.M.!!!

    TIA,
    Donna

  5. #5
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Apart from that being cheating - sure:

    retail.value.replace(/\(\d\)\+\.\d\+/, /\1\.95/);

    ( untested - as per usual )

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  6. #6
    SitePoint Zealot eStudio's Avatar
    Join Date
    Dec 2001
    Location
    NE Texas
    Posts
    153
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cheating? how so?

  7. #7
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lol - i'm only joking with you - silly!

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  8. #8
    SitePoint Zealot eStudio's Avatar
    Join Date
    Dec 2001
    Location
    NE Texas
    Posts
    153
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)


    so I assume it would be safe to lookup 'replace' to figure out what the code you posted actually does?


    Thanks again as always,

    Donna

  9. #9
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's a regular expression.

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---


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
  •