PDA

View Full Version : Populating drop down boxes dynamically


ryk
5-19-04, 05:31 AM
I'm sure this will have been asked before, but I'm not having any luck with the search function on this new style forum.

I wish to populate a drop down "select" list (of car manufacturers) with names from MySQL db, and then dependent on the result, populate a second list with the models, again from data in the db - and then display the results of the combination.

I wish to display only the info in the db.

Can anyone recommend a good tutorial on populating drop-down lists aimed at beginners to PHP?

Also, nothing to do with PHP, mysql or Powweb, but can anyone tell me where the setting is in Win XP/IE6 that turns on/off the display of previously used terms in a search box?

Dabrowski
5-19-04, 05:46 AM
You talking about Auto complete in form boxes? Internet Options>Content tab>Auto complete button. Make selections.

Pulling info from a db and plugging it into a drop down is pretty easy, but I don't know about the other part. I'm not sure how to make PHP effect a response immediately, without submitting. It may be some client-side scripting that does that, but I know I've seen it. Even on this site (on the old version), you could view your subscribed threads, and then select the time span from a drop down, and it would submit.

Again, I'm guessing it's JavaScript onSelect or something. I don't know anything about it.

ryk
5-19-04, 06:31 AM
Thanks! "Auto complete" was the phrase I couldn't remember.

With regard to my first question, I've found lots of possibilities through Google - was just hoping someone can recommend a specific one.

HalfaBee
5-19-04, 06:32 AM
For the auto complete problem look in
Tools->InternetOtions->Content
I think the autocomplete section is where to look.

Chinchilla
5-19-04, 09:51 AM
Simply and w/o getting into too much detail you could setup a series of iframes and use a javascript onChange(); to reload the next frame down as you narrow the fields. Each Frame would simply be a php page w/ a while loop.


So:


<select name="category1" onChange="customFunctiontoReload()">
<?
while($r = mysql_fetch_array($results) {
// Where results is the query from the DB

echo "<option value='".$r['option_idx']."'>".$r['option_textual']."</option>";
}
// Where "option_idx" should be the index reference to retrieve this option
// and "option_textual" should be the End User Readable Version of the name
// you want them to Select
?>
</select>

or something along those lines =p

ryk
5-19-04, 10:03 AM
Many thanks. :)