jtrovato
11-17-2003, 09:41 PM
I have 3 drop down menus I want to populate each drop down as they select what they want.
Once they select the first drop down, I want it call an MySQL database to get the data for the menu option below it and so on.
I have seen this on other sites and I like the way it works.
I do hope you guys can help out
THANKS!!!
Burhan
11-18-2003, 02:47 AM
You can attach a function to the onchange event so that as soon as a user selects an option -- the page refreshes to load the other select menu.
If you can pre-fetch the mysql data for all available options -- then you can populate the drop down via javascript (which would save a trip to the server).
jtrovato
11-18-2003, 01:14 PM
Thank you for the information.
I don't mind if it calls the server each time they select, it's not going to be a high volume site. The reason for this is to make life easier for the end user.
I don't know the java script code to refrash the page and send the page the ID or value of the select field.
JavaScript can be turned off, so it's better to generate select menus on server side.
jtrovato
11-18-2003, 09:43 PM
Not sure what you mean by select menus on the server side?
jtrovato
11-23-2003, 11:41 PM
How do you creat server side menus?
Burhan
11-24-2003, 06:35 AM
What null means is that write the HTML for the select menu in PHP (which runs on the server).
Something like this :
/* Assuming $row contains the result of a database query sample data could be like
$row[1] = "Honda";
$row[2] = "Toyota";
etc,
*/
echo "<select name=\"foo[]\">\n";
echo "<option value=\"NULL\" selected>Please select a brand</option>\n";
while(list($key,$val) = each($row))
{
echo "<option value=\"".$key."\">".$val."</option>\n";
}
echo "</select>\n";
The above code would produce
<select name="foo[]">
<option value="NULL" selected>Please select a brand</option>
<option value="1">Honda</option>
<option value="2">Toyota</option>
</select>
jtrovato
11-24-2003, 11:17 AM
thank you for that. I know how to create server side select menus,
I have 3 drop down menu's that I want to propulate with Mysql data. The second 2 will be left blank until the first one is selected, once they select the first one the second one is then populated the correct data. Once the second menu is selected the third one is the populated with the correct data.
I can load all the data into array's is nesessary.
Thanks,