Using Drupal 6's form ahah to have one dropdown field update the values of a second dropdown field I am working on a pair of form fields the directly effect one another. Specifically the problem I am dealing with is that we have thousands of groups users can join on this website that I have been working on. We are creating some administrative analytics forms for the site. Part of those forms is filtering by group.

The problem is that most of the people don't know the name of a group off the top of their heads, only what it starts with. So instead of using auto-complete we came up with two dropdowns. The first contains the options A through Z, letters of the alphabet which the group names begin with. The second dropdown contains all of the groups beginning with the selected letter.

The concept is simple enough and we were able to implement the AJAX pretty easy with jQuery. But this causes validation errors. After some research I found that this has to do with Drupal form caching. The solution is to use the ahah functions.

The problem with that is that all the instructions I have found so far deal with ahah actions for the specified field updating itself, not another field. So I am trying to figure out how to get the list of letters to update the group list using ahah and registering the new values with the form cache.

One solution I found was to simply load all the values on the page in a hidden dropdown and then just load up those in the set in the visible one as needed. But that creates a bunch of problems because the client uses almost exclusively IE and we have seen IE choke when given huge lists like that. Especially with the lists stored in JavaScript. So we need a light-weight solution.

Any thoughts? Ideas?
There's comprehensive example code in the Examples module that shows how to do this.

In the dependant_dropdown.inc file of the ahah_example module, you'll find an example form that does exactly what you're looking for. It's very well commented and should guide you through the process pretty well.

There's also a companion tutorial for the ahah_example module which would be worth looking it as it has more code examples.