Funbrain - Find jobs - Debt Consolidation - Find jobs - Expekt bonuses

PDA

View Full Version : On selection, change contents of combo box


lost
Oct 31st 2005, 6:47 am
I have 2 combo boxes, one for category and one for type.
On start the category combo box includes a list of all categories, i.e. books, video, music, dvd. the type combo box includes nothing.
Once a category form the combo box has been selected, the type combo box gets populated with the specific types for that category.

Anyone know how to do this???

Weirfire
Oct 31st 2005, 7:34 am
When you say combo box do you mean the select option form list?

If so then yes I know how to do this.

TheHoff
Oct 31st 2005, 7:48 am
Better to do it in Javascript and avoid the page refreshes. Use PHP to build the Javascript lists.

http://www.felgall.com/jstip22.htm <-- a good tutorial on it

lost
Oct 31st 2005, 7:48 am
yes that is what i mean, can you help me?

lost
Oct 31st 2005, 7:50 am
Thanks vbMechanic...thats exactly what i need :)

Weirfire
Oct 31st 2005, 7:57 am
Thats almost exactly what I had as well.

You could use some css to hide the list that doesnt have anything until the first list has been selected :)

lost
Oct 31st 2005, 8:29 am
what's css??

Weirfire
Oct 31st 2005, 8:52 am
cascading style sheets

http://www.w3schools.com/css/default.asp


It helps you layout the html on your webpages and you can use it to hide unwanted code.

mnemtsas
Oct 31st 2005, 12:40 pm
I do this in several spots. You need to build up a js array for each selection list. Then on the onclick event of the first box you fill the contents of the second box with appropriate js array. When I get to work I'll post the js I construct from php and the code I use to construct it.

sarahk
Nov 1st 2005, 11:25 am
If you need to query the database to get the results for the first list a technique like I use here (http://sarahk.pcpropertymanager.com/muck/example.php) may be useful but these days people use AJAX (http://en.wikipedia.org/wiki/AJAX).