Dependent List Boxes with PHP
I would like to create two dependent lists box with PHP/MySql and Dreamweaver MX.
I read the tutorial in Macromedia web site, but it did not help me.
Can somebody suggest a starting point ?
I read the tutorial in Macromedia web site, but it did not help me.
Can somebody suggest a starting point ?
Comments
Dynamic Data Source is the answer
There are a couple of steps that I use to do this. The first is to create the recordset you need to populate the list box.
The second is to set the list box to the dynamic data source by clicking the lightning bolt icon on the listbox form item. This will pop up the data source window. Select the recordset and database connection. Select the values and items for the recordset you created. Done.
To make two list boxes one dependent on the other. Use two separate forms and in the name for the first listbox item name it someting like urlvar. Set the form to GET and add a onchange="form1.submit()" clause to the listbox.
when building the dataset for populating the second box, get the urlvar and filter the data on that. for example:
Listbox 1 poplulates with car manufacturers and a key value like 1 ford 2 chevy 3 bmw
the user selects bmw and the page refreshes with test.php?urlvar=3
You then create a dataset on car models which would include all the models and their corresponding manufacturers. the sql looks something like select car.color from car where car.manufacurer = colname
Colname is actually a dreamweaver default which creates a $http_get_vars['urlvar'] and returns it into the select statement.
When you build the listbox set the options from the second data source.
Done!
RE: Dynamic Data Source is the answer
Maybe the one that requires no refresh that he want (and me too).. i see some kinda javascript and array that built from database query..
i found many link but it shows mainly for ASP
You must me logged in to write a comment.