Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Dec 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Help with assigning values to form options?

    Hey,

    Let me try to do my best to explain this...
    I have a business website that specializes in building custom computers. Customers can use our online form to select components for their computer from various categories (Hard drive size, processor, memory, ect..)

    Take a look at the page here: www.plugcomputers.com/amdschedule.php

    As you can see there are many radio buttons with different computer part choices. I wanted to add some way to assign a dollar value to each different part, so the customer knows how much its costing them with each upgrade. If you scroll to the bottom of the page you will see some red text, I want that price to reflect the sum off all the choices they made above. Adding up all the different upgrade dollar amounts so that they have an idea how much their computer will be while selecting components.

    The current red number at the bottom is the base price with all the default selected values.

    For example, in the first category "Processor"
    The base price includes the AMD x2 3800+, If i wanted the upgrade price for the next option (the AMD x2 4400+) to be +$50 how can I get that into the form so when the user clicks that radio the price at the bottom automatically adds $50?

    Thank you and I appreciate any help...
    Plug Computers - Custom Intel and AMD Gaming Computers - Visit Today!

  • #2
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    didnt you post this exact question a few months back?
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.

  • #3
    New Coder
    Join Date
    Dec 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I did, but the response I got never worked out. I was hoping maybe there were some new people on here that could help me get this figured out. I appreciate any help...
    Plug Computers - Custom Intel and AMD Gaming Computers - Visit Today!

  • #4
    Regular Coder
    Join Date
    Jan 2006
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts
    you could assign a "fake" attribute to each radio button.

    example:
    <input type="radio" name="cputype" value="amd" priceattribute="$165.99"/>


    and then with javascript i believe you can use getAttribute to get the value of that.

    document.formname.cputype.getAttribute("priceattribute");

    its a bit of a work-around, but its a nice easy way to associate information like this with a specific form item.

    hope that helps.

  • #5
    New Coder
    Join Date
    Dec 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I can't really figure that out JayStang...can you be a bit more descriptive? How can i get that to total at the bottom of the page?
    Plug Computers - Custom Intel and AMD Gaming Computers - Visit Today!

  • #6
    New Coder
    Join Date
    Jan 2007
    Posts
    93
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is probably not the right way to do it, but it works:

    Add to each product div an id and a value like this:
    <div class="item" id="item0" value="100.00">

    insert: onclick="calc(0,120.20)" for each input option.

    First number is the product group and the second is the price.

    A onLoad call the calc(x,xx.xx) would be good to show initial total.

    Code:
    function calc(id,amount){
     document.getElementById('item'+id).value= amount
     var total = 0
     for (var i=0; i<17; i++){   // you have 17 product groups
      total += parseFloat(document.getElementById('item'+i).value)
      }
     document.getElementById('total').innerHTML = total
     }
    replace your red total text with this.
    <span id="total"></span>
    Last edited by tonyp12; 02-27-2007 at 03:49 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •