OK. I'll have a go at explaining this one.
Lets assume that you have your first select built as follows -
$sel1 = "Select 1:<SELECT name=\"sel_name_1\" onChange=\"this.submit()\">";
$sel1 .= "<OPTION value=\"1\">1</OPTION>";
$sel1 .= "<OPTION value=\"2\">2</OPTION>";
$sel1 .= "<OPTION value=\"3\">3</OPTION>";
$sel1 .= "</SELECT>";
You need the FORM ACTION to point to itself -
$output = "<FORM name=\"multi_selects\" method=\"POST\" action=\"$PHP_SELF\">";
If you have no value for $sel_name_1 when the page loads the second select will be empty -
if (!$_POST['sel_name_1']) {
$sel2 = "Select 2:<SELECT name=sel_name_2>";
$sel2 .= "<OPTION value=\"\"> </OPTION>";
$sel2 .= "</SELECT>";
}
if there is a value for $sel_name_1 you retrive the data for the second select -
else {
$sel2 = "Select 2:<SELECT name=sel_name_2>";
// do query to find data to build second select
// you then loop through the query results to build the data for the select
$result = ;// do your query
while ($row=mysql_fetch_array($result)) {
$sel2 .= '<OPTION value="' . $row['value'] . '">' . $row['text'] . '</OPTION>";
}
$sel2 .= "</SELECT>";
S**t. I've got to go now. I hope you can get the idea. I will post an example to go with this later on in the day.
Hope this helps 😉