1. Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Creating conditional drop-down lists for a website.

Discussion in 'Programming & Webmastering' started by xazraelx, Oct 8, 2008.

  1. xazraelx New Member

    Joined:
    Oct 23, 2007
    Messages:
    179 (0.08/day)
    Thanks Received:
    10
    Is there a way to create a conditional drop-down list. For example, let's say we're building a computer.

    First they choose a type of processor...if it's a socket LGA 775, then the motherboard will automatically narrow to only LGA 775 boards, but if they want a socket 939, it will only display socket 939 boards. I'm kind of on the beginner-intermediate level when it comes to programming, but I'm more familiar with java and C++ than anything. I'm trying to learn some html/css/etc, just to prepare some basic websites.

    Thanks TPU =)
  2. FordGT90Concept

    FordGT90Concept "I go fast!1!11!1!"

    Joined:
    Oct 13, 2008
    Messages:
    12,989 (6.44/day)
    Thanks Received:
    3,093
    Location:
    IA, USA
    PHP:
    <select name="something">
      <
    option value="return1">Option 1</option>
      <
    option value="return2" checked="checked">Option 2</option>
      <
    option value="return3">Option 3</option>
    </
    select>
    The code (server or client) basically has to produce the option rows and spit out the checked statement on the one you want automatically selected.
    Crunching for Team TPU
  3. DanTheBanjoman Señor Moderator

    Joined:
    May 20, 2004
    Messages:
    10,553 (2.91/day)
    Thanks Received:
    1,383
    Fill dropdowns from queries. You could read the selected item from another dropdown/checkbox/whatever and use that in your query.

    ie select * from motherboards where socket = whateverthedropdownsays. Of course your code would be generating the right query there.
  4. Oliver_FF

    Oliver_FF New Member

    Joined:
    Oct 15, 2006
    Messages:
    546 (0.20/day)
    Thanks Received:
    65
    You'll probably need to use javascript to show and hide items in the list on the fly by altering the styling.

    Or, if the pages are generated by the server and the page reloads when people pick things then you can use PHP or JSP's to spew out just the relevant rows.

    Start googling javascript events ;)
  5. DanTheBanjoman Señor Moderator

    Joined:
    May 20, 2004
    Messages:
    10,553 (2.91/day)
    Thanks Received:
    1,383
    Java, PHP, ASP or even Flash or Silverlight, all can do the trick. There simply needs to be some database backend. Could also be anything, probably some SQL variant.
    I'd say pick a platform first.
  6. FordGT90Concept

    FordGT90Concept "I go fast!1!11!1!"

    Joined:
    Oct 13, 2008
    Messages:
    12,989 (6.44/day)
    Thanks Received:
    3,093
    Location:
    IA, USA
    I agree. Seeing that you already have C++ experience, PHP would probably be the best way to go.
    Crunching for Team TPU
  7. DanTheBanjoman Señor Moderator

    Joined:
    May 20, 2004
    Messages:
    10,553 (2.91/day)
    Thanks Received:
    1,383
    Actually according to that logic ASP.NET would be easier. A lot less flexibility when it comes to server choice though.
  8. FordGT90Concept

    FordGT90Concept "I go fast!1!11!1!"

    Joined:
    Oct 13, 2008
    Messages:
    12,989 (6.44/day)
    Thanks Received:
    3,093
    Location:
    IA, USA
    I've never coded ASP.NET using C++ so I wouldn't know how sharp that learning curve is.
    Crunching for Team TPU
  9. DanTheBanjoman Señor Moderator

    Joined:
    May 20, 2004
    Messages:
    10,553 (2.91/day)
    Thanks Received:
    1,383
    It's .NET, VBA and C#.
  10. xazraelx New Member

    Joined:
    Oct 23, 2007
    Messages:
    179 (0.08/day)
    Thanks Received:
    10
    Thanks for all the replies - I hadn't taken a peek at this thread in a while. I'm going to hold off on this little learning experience for a bit, but I've used SQL before in a couple classes, and will probably be trying something using that and just accessing it. I certainly don't mind learning new things, nothing is ever useless, and may be back.

    Again, all the feedback is appreciated.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guest)

Share This Page