By j_ten_man on
I am trying to get a dropdown box that is populated based off the selection that a user makes in a previous dropdown. So I have two dropdowns (I really have 3, but I want to understand how to do this), and based off what is selected in the first dropdown, the second dropdown changes. I am looking for a good and clear example of how to do this. I found some information from drupalcamp in 2007 that was good, but the code doesn't work when I download it. I think that they are using 4.7 and I am using 5.0. Also, they never populate a dropdown which I need to do. Please provide any code snippets or good tutorials on how to do this.
Comments
subscribe
subscribe
to what??
to what and where?
To this thread so I can
To this thread so I can track replies! I'd like to know the answer as well.
=-=
common practice for users to do something like that so that the thread is added to their personal tracker page.
edit
Two modules that come to mind:
activeselect (more for developers)
hierarchical_select
both in the downloads area.
_____________________________________________________________________
My posts & comments are usually dripping with sarcasm.
If you ask nicely I'll give you a towel : )
check out the modules
check out the modules page--- If I remember correctly there's a couple of modules that address this need.
Working with hierarchial select
I think that hierarchal select is going to be the best bet, but I was wondering if there is a way to use this not with a taxonomy. I have a large database and putting them into a taxonomy doesn't seem like the best idea. So, what I want to do is when someone changes the select box, it queries the db and puts those values in the next drop box. Is this possible, or will activeselect be better? I am looking for a good example of how to do this as well if someone can direct me to where I might be able to find one...
Not working completely...
So, I have started working on this a little, and it is beginning to work, but I have a couple of questions. Here is the code I have for my select box:
I have also defined all the necessary hooks to populate the dropdowns. The problem is that with this code, I have a multiple select box, and right below that is a drop-down box. The multiple select box has the same values as the dropdown directly below it (this is because I set the root values of the dropdown to the same thing). If I change the value of save_lineage from TRUE to FALSE then it changes the multiple select box to just a normal dropdown with the same values. Why does this happen?
Populating the Dropdowns
How exactly is this done? I've read the Hierarchical Select (HS) API.txt and still unclear as to how the $options get set up into the separate dropdowns and how the hooks integrate from a custom module to do this.
I'm looking to populate an HS with non-taxonomy values--user & profile fields. Basically, I'm trying to take different items entered into different fields and produce a hierarchy from them based on my own algorithm.
I want it to be scalable and not load the entire heirarchy at once--only populate the appropriate children based on the parent choice, and I'm having a hard time understanding the big picture on how to work this between HS's Form API usage and the hooks.
Any suggestions or clues on where to look would be most appreciated.
Thank you,
Stephen
--
Web: http://digitalfrontiersmedia.com
Cell: 941.773.2036
Phone: 941.677.DFM1 ( 941.677.3361 )
Skype: DigitalFrontiersMedia
Twitter: DigitalFrontier
--
Joint sponsorship - Hierarchical Select
The new module Hierarchical Select will have two new major features:
I’m sponsoring a small part of Hierarchical Select development. If others want to do a joint sponsorship you are welcome. Beta testers are welcome too. Development updates are posted by Wim at: http://drupal.org/node/226067 Wim can be contacted at: http://drupal.org/user/99777 or http://wimleers.com/contact