SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    May 2005
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript Select box help

    Does anybody know how i can update a price... based on input in a select box... i have tried modifying my own code but i cant because i am useless with JavaScript... please help!

    for example select box1 has values of 50, 100, 150

    then select box 2 has 200, 250, 300

    if i chose the first option in the first box and last one in the second one... it would display 350...

    can anybody help?

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Portsmouth UK
    Posts
    1,499
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Common problem

    the value of the option is a string
    if val='10'

    val+10 = 1010

    so Number(val)+10 = 20;

    or parseInt(val)+10 = 20;

    or parseFloat(val)+10 = 20;

    is ok with *, / as Javascript knows what you want by auto variable typing

  3. #3
    SitePoint Member
    Join Date
    May 2005
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    Im not really any good at javascript... so could anybody possibly write a code for me?? sorry if thats too much to ask...

  4. #4
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Portsmouth UK
    Posts
    1,499
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://www.vicsjavascripts.org.uk/Fo...Compendium.htm

    or be more specific on requirement

  5. #5
    SitePoint Member
    Join Date
    May 2005
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok... for example i have a shopping cart kind of thing... but the order will be placed via email etc... in this case computers... custom built...

    as the user selects the individual components... i want it to update the total price of the order in a text box perhaps at the bottom...

  6. #6
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Portsmouth UK
    Posts
    1,499
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://www.vicsjavascripts.org.uk/Fo...pendium.htm#f3

    gives an example of that with sub and grand totals

    perhaps better you post a sample form for modification

  7. #7
    SitePoint Member
    Join Date
    May 2005
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    for the form thing... well all i need is a kind of shopping cart... the user selects the components... and then the total of all the components they select is shown in a text box or the like at the bottom of the page...


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
  •