jeanna
jeanna

Reputation: 33

dynamic dropdowns

i want three dropdowns. The second and third dropdowns need to be dynamically populated by the previous selections. I believe this can be done with ajax & php querying my database.The three dropdowns are puuling data from three different columns in one table.
An example would be something like this... http://www.kbb.com/used-cars#

Can anyone point me in the right direction to get this accomplished?

Any help is MUCH appreciated!

Upvotes: 3

Views: 358

Answers (2)

usoban
usoban

Reputation: 5478

HTML:

three select fields

JavaScript:

use jQuery or some other framework. Then bind "onchange" event for given select field to some javascript function, which makes AJAX request to the php script and sends the selected value.

PHP:

read the value, make the decision and return results. Result can be either HTML or JSON, depends what you really need.

When Javascript gets the results from the given PHP script, you should provide the callback function, which populates the other two fields based on returned value.

Upvotes: 1

Related Questions