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 4 of 4
  1. #1
    New Coder
    Join Date
    Dec 2010
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Drop-Down Menu Contest

    What I'm looking for is a series of related drop menus that change the strings involved based on customer’s choice and change the prices.
    so it would need some sort of math functions..

    so for example:
    customer sees one drop down menu titled: manufacturers
    once they choose something, the drop menu under it automatically populates new data

    Manufacturers
    • HTC
    • Motorola
    • Blackberry
    • Nokia
    • Sony
    • LG
    Network Providers:
    • Rogers
    • Fido
    • AT&T
    • Tmobile
    • Telus
    • Verizon
    there would need to be if statements to cross reference, so
    if(choice1==HTC && choice2==Rogers)
    cost=15$;
    else if (choice1== etc etc etc....)

    Does anyone have any idea how to do this? I'm looking to have it in Java.

    Regarding the contest, Help me decide what the prize will be. Smile

    Thank you,

    Has

  • #2
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,077
    Thanks
    38
    Thanked 498 Times in 492 Posts

    Question More information needed...

    Would need a bit more information than you have provided thus far.

    1. Will all Manufacturers have access to ALL Network Providers or just SOME? If some, which?
    2. What prices, or formula applied to a base price, will be applied to each combination?

    I don't think your idea of numerous if statements is the best choice, but it could be done.

  • #3
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,077
    Thanks
    38
    Thanked 498 Times in 492 Posts

    Lightbulb Something to consider ...

    Major assumption coming ...

    You need costs associated with DIFFERENT manufacturers and providers.

    Change value to associate different providers with different manufacturers
    and enter costs associated with the selections chosen as in example below.

    Code:
    <html>
    
    <head>
    <title>Product Price Data Collection</title>
    <script type="text/javascript">
    // From: http://www.codingforums.com/showthread.php?t=213522
    
    function AddItems(Items,IDS) {
      var sel = document.getElementById(IDS);
      for (var i=0; i<Items.length; i++) {
    //    sel.options[sel.options.length]=new Option(Items[i],Items[i],true,true);
        tmp = Items[i].split(':');
        sel.options[sel.options.length]=new Option(tmp[0],tmp[1],true,true);
      }  
    }
    function Populate(IDS,Items) {
      var sel = document.getElementById(IDS);
      sel.options.length = 0;  if (Items == '') { return; }
      AddItems(['Select'],IDS);
      var ItemArray = Items.split(',');
      AddItems(ItemArray,IDS);
      sel.selectedIndex = 0;
    }
    
    function showCost(info) { alert('Cost: $'+info); }
      
    </script>
    </head>
    
    <body>
    <form name="convert">
    
    Manufacturer: 
    <select name="SBox1" id="SBox1" onChange="Populate('SBox2',this.value)">
     <option value="">Choose Manufacturer</option>
     <option value="Rogers:10,Fido:20,AT&T:30,Tmobile:40,Telus:50,Verizon:60">HTC</option>
     <option value="Fido:10,AT&T:15,Tmobile:20,Telus:25,Verizon:30">Motorola</option>
     <option value="AT&T:10,Tmobile:12,Telus:14,Verizon:16">Blackberry</option>
     <option value="Tmobile:10,Telus:20,Verizon:30">Nokia</option>
     <option value="Telus:10,Verizon:23">Sony</option>
     <option value="Rogers:60,Fido:50,AT&T:40,Tmobile:30,Telus:20,Verizon:10">LG</option>
    </select>
    
    Provider: 
    <select name="SBox2" id="SBox2" onchange="showCost(this.value)"></select>
    </form>
    </body>
    
    </html>

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,210
    Thanks
    75
    Thanked 4,343 Times in 4,309 Posts
    Does anyone have any idea how to do this? I'm looking to have it in Java.
    Then you are posting in the wrong forum.

    This is the JavaScript forum.

    About the only thing Java and JavaScript have in common are the first 4 letters of their names.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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