FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


populate dropdowns on select





Dark-Tech
I have a form with two dropdown menus among other fields that are populated via a database using php....

How can i make it so that on select of an option in field one it populates field 2

see i want field one to be building numbers and field two to be a list of the rooms in the building

can anyone help or refer me to some kind of combo with javascript that will work... I couldn't figure out how to use them in conjunction to do this
badai
on the first select use on select to run a function.

on that function you can change the second select options.

here's reference how to manipulate your second combo

http://www.w3schools.com/htmldom/dom_obj_select.asp

first you truncate all it options.

then you get the list from db and add it back one by one.
kv
to populate values from db, you will have to use ajax. Otherwise, you can load all the info (room numbers for all buildings) in the page itself (in a hidden field or javascript variables/arrays), then just manipulate combo object on select.
malcolmpreen
I wanted to do a very similar thing myself.... searching on google provided me with explanations and sample code... I have a triple drop down.... they have to be filled in order...

Box1 is one of many from a particular database table....
Box2 is one of many from a second table (chosen by the first selection)
Box3 is one of many from the second table (same list as before... but excluding the item chosen for box 2)

Changing any of the boxes, results in the later boxes being reset....

All coded with php/mysql - and is basically a customisation of the samples I found on the net...

Good luck, Malcolm
Related topics
Select and click
Sound problems!
myBBoard - Installation Tutorial
Opera 9.0 Technology Preview 2
$_Post Variable for Options from Select Types?
Select more than 1 field in a database
Automatism select mirror sites!
how do you create an Xanga layout?
select boxes value change?
PhpNuke Installation Tutorial
Need Help integrating php variable into mySQL SELECT query
How? : Javascript Select All [solved]
Just uploaded. Shouldn't be jibberish.
Shortcut to select the temporary boot priority
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.