Results 1 to 7 of 7

Thread: Drop-Down Box price addition help

  1. #1
    Join Date
    Jun 2006
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Drop-Down Box price addition help

    Hello all,

    Im new to these forums and new to javascript. I was wondering if anybody would be able to help me with the script that i am using. I am making a website that people would be able to go to, to build a computer and to have a thing that automatically updates the price as they choose the items. Similar to Dell's setup on their site, but simpler, with drop-down menues.

    Example:
    http://configure.us.dell.com/dellsto...XPS600F4&s=dhs

    Here is the site that i want the script to work on, im still working on it, but it should give you enough information to let me know what i need to do to make it work with drop down boxes.

    http://www.oharanetworks.com/jcr/build/test.htm

    If anyone could give me any help, that would be great. Thanks.

  2. #2
    Join Date
    Mar 2006
    Posts
    600
    Thanks
    5
    Thanked 4 Times in 4 Posts

    Default

    it would be cool if you could use this in it.
    http://www.dynamicdrive.com/dynamici...bodescribe.htm

  3. #3
    Join Date
    Jun 2006
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Yes, that would be cool too, I think i will use that script, thanks. But i still need help getting the calculate price thing working, as posted above.

    Help Please

    Thanks

  4. #4
    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

    HTML Code:
    <select size="1" name="D1" onchange="this.form.price1.value=this.options[this.selectedIndex].value;calculate()">
    <option selected>Select Processor</option>
    <option value="639.00">AMD Athlon 64 FX55 San Diego 2000MHz HT Socket 939 [Subtract $172]
    </option>
    <option value="811.00">AMD Athlon 64 FX60 Toledo 2000MHz HT Socket 939 Dual Core [Add $42]
    </option>
    <option value="853.00">AMD Athlon 64 FX57 San Diego 2000MHz HT Socket 939 [Included in Price]
    </option>
    </select>
    Last edited by jscheuer1; 06-02-2006 at 06:09 AM.
    - John
    ________________________

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

  5. #5
    Join Date
    Jun 2006
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    SWEET! It works, thank you so much!
    But how could i make it so that when, for example the option with the "[Included in Price]" is initially selected and it initially has the total in the box?

    Any help would be wonderful.

    Thanks again
    Last edited by viper102464; 06-02-2006 at 06:16 AM.

  6. #6
    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

    HTML Code:
    <html>
    <head>
    <title>test</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <body bgcolor="#000000" onload="calculate();">
    
    <script type="text/javascript">
    function cent(amount) {
    return (amount == Math.floor(amount)) ? amount + '.00' : ( (amount*10 == Math.floor(amount*10)) ? amount + '0' : amount);
    }
    
    function calculate() {
    var p1, p2, p3;
    p1 = test.price1.value * 1;
    p2 = test.price2.value * 1;
    p3 = test.price3.value * 1;
    total_price = p1 + p2 + p3;
    test.total_price.value = cent(Math.round(total_price*Math.pow(10,2))/Math.pow(10,2));
    }
    
    </script>
    
    <form name="test" method="post" action="">
    <input type="hidden" value="853.00" name="price1">
    <input type="hidden" value="202.00" name="price2">
    <input type="hidden" value="1000.00" name="price3">
    
    <p><font face="Arial" size="2" color="#FFFFFF">Total: </font>
    
    <input type="text" name="total_price" font="arial" size="10" readonly></p>
    
    <p>&nbsp;</p>
    <p><font color="#FFFFFF" face="Arial">Here is what I want to work:</font></p>
    <p>
    <b><font face="Arial" size="2" color="#FFFFFF">Processors</font></b></p>
    
    <p><select size="1" name="D1" onchange="this.form.price1.value=this.options[this.selectedIndex].value;calculate()">
    <option value="639.00">AMD Athlon 64 FX55 San Diego 2000MHz HT Socket 939 [Subtract $172]
    </option>
    <option value="853.00">AMD Athlon 64 FX60 Toledo 2000MHz HT Socket 939 Dual Core [Add $42]
    </option>
    <option value="811.00" selected>AMD Athlon 64 FX57 San Diego 2000MHz HT Socket 939 [Included in Price]
    </option>
    </select></p>
    <p>
    <b><font face="Arial" size="2" color="#FFFFFF">Memory</font></b></p>
    
    <p><select size="1" name="D2" onchange="this.form.price2.value=this.options[this.selectedIndex].value;calculate()">
    <option value="202.00" selected>CORSAIR XMS 2GB (2 x 1GB) 184-Pin DDR SDRAM DDR 400 (PC 3200) Unbuffered Dual Channel w/ Platinum Heat Spreader [Included in Price]
    </option>
    <option value="464.00">CORSAIR XMS 4GB (4 x 1GB) 184-Pin DDR SDRAM DDR 400 (PC 3200) Unbuffered Dual Channel w/Activity LED's [Add $262]
    </option>
    <option value="404.00">CORSAIR XMS 4GB (4 x 1GB) 184-Pin DDR SDRAM DDR 400 (PC 3200) Unbuffered Dual Channel w/ Platinum Heat Spreader [Add $202]
    </option>
    <option value="232.00">CORSAIR XMS 2GB (2 x 1GB) 184-Pin DDR SDRAM DDR 400 (PC 3200) Unbuffered Dual Channel w/Activity LED's [Add $30]
    </option>
    </select></p>
    <p>
    <b><font face="Arial" size="2" color="#FFFFFF">Video Cards</font></b></p>
    <p><select size="1" name="D3" onchange="this.form.price3.value=this.options[this.selectedIndex].value;calculate()">
    <option value="590.00">Dual XFX GeForce 7900 GT EXTREME (520MHz Core Clock) 256MB GDDR3 PCI Express x16 [Subtract $410]
    </option>
    <option value="1000.00" selected>Dual BFG Tech Geforce 7900GTX (670MHz Core Clock)512MB GDDR3 PCI Express x16 [Included In Price]
    
    </option>
    </select></p>
    </form>
    
    </body>
    </html>
    Last edited by jscheuer1; 06-02-2006 at 06:59 AM.
    - John
    ________________________

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

  7. #7
    Join Date
    Jun 2006
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Awesome! Thanks for all your help!

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
  •