As a nice change of pace, I thought I would actually post some working code here for people to use. However, I wouldn't mind suggested improvements.
This code is useful for creating AJAX Chained Selectors (one select box populates the next, and so on). It is based on the Prototype javascript library.
The function expects the id field value of the "source" select box, the id value of the "destination" box, and whatever action that AJAX will have to call to retrieve the set of results (in JSON format) to populate the destination select box with. The JSON fields are expected to be "id" and "name". (Note: personally, I use a
Struts action that retrieves a collection, then uses json-lib to convert the collection to a JSON array, then uses HttpServletResponse.getWriter() to print it out.
Anyhow, here you go: