Forum


00:51

15/07/2010

Inside our Edit Form, we have one field (edittype=select) that must dynamically update options available based on the realtime selection value of another field (edittype=select).
For example if "Hair Color" was selected in the first select menu, the values in the second menu would auto-populate with options of "Brown", "Blond" and "Brunette". If "Fruit" was selected in the first menu, the second menu would re-populate with options "Orange", "Apple", "Pear".
How would we go about this?
If i were trying to solve this problem i would ...
1) populate the second SELECT with all possible values (eg. all hair colours, all shirt sizes, etc.)
2) attach a function call to the onchange event of the first SELECT
3) in this function, i would loop through all OPTION's in the second SELECT, and make them either hidden or visible, depending on the value of the first select
Maybe theres a better way, just an idea 🙂 I hope it helps!
Cheers,
Michael
Yep I think your right, if the number of OPTIONs is huge, then it would be best to load them via AJAX when needed.
It would be even better if you prevent loading the OPTIONs a second time if they've already been loaded.
Perhaps, it would be easiest to ...
a) Have a seperate SELECT for each of the different types, and hide/unhide the whole select depending on what is selected in the first SELECT
b) When your un-hiding one of these SELECTs, you could check if it has already been loaded,and if not then load it up via AJAX
Most Users Ever Online: 715
Currently Online:
57 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66