[thelist] Javascript: Multiple Selects

VOLKAN ÖZÇELİK volkan.ozcelik at gmail.com
Wed Nov 16 10:09:23 CST 2005

I did something similar recently using ajax and dom.

to give pseudocode

1. fill select 1 from db (using element.appendChild) from an xml
response received from the server after page loads.

2. when the first select changes post the value to server, get another
xml response,

2.1. (you need to implement some code in between to keep things in sync)

3. remove all child nodes of the second select (if already filled from
a former action)

4. append the nodes that come from the new xml response to the second select.

it's not that hard if your specifications allow use of DOM.

One thing you have to take care is empty text nodes. You had better
write a sweeper function for it.

Note depending on your particular case ajax may not be required. You
can re-load the selects from global arrays that serve as hashes etc.

Hope it gives some idea,
Volkan Ozcelik
+>Yep! I'm blogging! : http://www.volkanozcelik.com/volkanozcelik/blog/
+> My projects/studies/trials/errors : http://www.sarmal.com/

More information about the thelist mailing list