...

View Full Version : Dynamic Select Box Generation



ffsja
03-02-2007, 12:37 AM
Hello everyone,
I'm interested in creating two drop down boxes on my html form that are populated with data from a mysql database. The data for the first box is course titles and the data for the second is course sections. So far this is no problem.

BUT, since the data in both select boxes is related (ie. each course title has a corrresponding course section)...I would like the user (ie. the student) to be able to select either/or and have the other select box automatically pick the associated value from the mysql database.

Anyone know how to approach this?

thanks,
sage

meth
03-02-2007, 03:49 AM
This has to be done with javascript if you dont want an overly complicated solution. The first menu has to be a jump menu that reloads the page with a GET var using javascript. The second menu takes the GET var and uses it in the WHERE clause of the query whose resultset populates the 2nd drop menu.

Inigoesdr
03-02-2007, 07:43 PM
You could do it with AJAX to avoid reloading the page, or populate a Javascript array on pageload and just reference it when the menu changes(if your menu isn't ridiculously large).

aedrin
03-02-2007, 08:11 PM
The first menu has to be a jump menu that reloads the page with a GET var using javascript.

The issue is that most people who use these kind of forms find the experience unpleasant. So I'd recommend against this method.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum