Jump to content

Multiple Dynamic DropDown List


oaklinedesign

Recommended Posts

Hey,

 

I'm obviously new here. I some php knowledge, but not very much MySQL knowledge. Any help would be hugely appreciated. Perhaps even a trade of some graphic design work for some help making this come to reality.

 

I have a client who would like to use multiple dropdown list to narrow a selection of items to just a two or three.  There are approximately 80 items right now, each with 5 different attribute.

We would like it so that each time you select from one dropdown an attribute the next dropdown dynamically changes and only shows attributes that relate to the remaining item. Example DropDown1 is the Continent (North America, Asia, etc), DropDown2 contains a list of the countries, DropDown3 contains a list of the providences/states/regions, DropDown4 contains a list of the cities. Once the all the preceding lists are chosen the user is then shown in plain text a list of the Stores in that city.

 

Thats not actually what we need narrowed down, so the database/tables wont actually be containing every city in the world—as I said only 80 items.

 

What do you think would be the best way to do this? Would using an xml or javascript table be easier than using mySQL and PHP? Do you know any tutorials on how this might be done. I've seen things that show 2 levels of dropdowns, but not 5 or 6 (as I need).

 

Please, please, please, please help.

 

 

Link to comment
Share on other sites

Not to sure how to do this but it looks like you could use some ajax, which I know nothing about really.

You could use an i-frame as well maybe, I'm new as well. You could have one drop down box show in

the page in an i-frame with your choices, once they pick one you have it refresh the frame. Using the

choice they made you query your DB and make the second drop down box form that info.

 

Not sure if this is right way to go about it but it's where I would likely start, again I'm new to this

as well..

 

Stephen

Link to comment
Share on other sites

You had it with ajax but definitely not with iframes as they are deprecated, or just not used, I'm pretty sure. I could help code this but I am not really looking to get anything designed and as this is a help forum I can't do it all for you.

What would you use instead of iframes then?
Link to comment
Share on other sites

Why not use templated HTML for the drop down lists, then you don't have to worry about re-writing them etc.

And for everytime they get set, create a new drop down using the template and get the data from a mysql db, replace the templated tags with the data from the database and repeat.

 

Here is a good example of a template class: http://www.phpro.org/classes/Template-Class.html

 

Template:

<select name="{tpl.SelectName}">
    <option name="{tpl.Option"}>{tpl.OptionValue}</option>
</select>

------------------------------

$this->tplSet('tpl.SelectName') = mysql_result(mysql_query("SELECT * FROM `someTable` WHERE 1=1"));

$this->tplReplaceAll();

 

 

Then using Ajax/Javascript repeat it all and create a new drop down box using the results for the search query.

 

Sorry if that doesn't make too much sense, It's early! lol.

 

Hope this helped!

Link to comment
Share on other sites

I don't see what iframes or template classes have to do with anything the OP asked.

 

The simplest way to accomplish this would be to pass selections in the querystring, using a Javascript onclick to refresh the page, narrowing the options in subsequent dropdowns where $_GET['value_of_first_dropdown'] is set.

 

To avoid refreshing the page, I'd suggest using jQuery to easily repopulate your dropdown menus from a simple PHP page loaded asynchronously.

 

In either case, you'll want to store all the options in a MySQL database table. Good luck.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.