Conservative Design: Hierarchical Select

This is a post in a series entitled Conservative Design Patterns for Form Elements.

For now, I’ll start off with an easy web component that a lot of you have probably already had some experience with. But, strangely enough, it is not included in any of the JavaScript libraries that are out there, that I’ve seen. If you know of one, go ahead and post it in the comments.

Hierarchical Select Boxes (sometimes called Dynamic Select Boxes if you’re doing a web search)

Behavior: 2 or more select boxes working in parallel, where selection of an option in a parent dynamically adjusts the options of the child.

Screenshot (Prior to any selection):
Prior to any selection

Screenshot (After an option is chosen in the first select box):
After a selection is made

Minimum Requirements for Acceptable Feature Set:

  • Must be able to handle any (reasonable) number of select boxes in a linear structure: parent elements only have one child.
  • Child select elements can be optional depending on parent selection. Maybe a continent doesn’t have any countries, so don’t display a child select element. It would be nice to have a visual indicator showing whether or not a parent option had children (triangle, folder(?), arrow or other customizable icon).
  • Must have functionality that allows it to be reset with the form reset button, as Matt Kruse has done (Example 3).
  • Load options in child select’s dynamically from multiple data sources (describe in raw HTML code, local JS file, remote JSON object or XML file using an XMLHTTPRequest)

Luxury Feature Set:

  • Must be able to nest select elements in a tree structure: selecting an option in a parent element could modify 2+ child select elements.
  • Could be able to modify the options for any element that displays options (Select1 or Select+ as described in the Conservative Design Post: Checkbox Group, Radio Group, Select Single or Multiple)
This entry was posted in Interface Design and tagged , , . Bookmark the permalink. Both comments and trackbacks are currently closed.
  • Hey! Use the magical power of RSS and Subscribe! Send me a tweet or a pull request!
  • Zach Leatherman is a Professional Front End Engineer. He loves building for the web and has been writing here since 2007. Feel free to stalk his résumé.

    He enjoys spending time with his beautiful wife Traci and their two Great Danes, Roxie and Ella. They also have a cat, a rabbit, goldfish, two poison dart frogs, and usually one or more tarantulas. Read more »

One Comment

  1. ahmad balavipour
    Posted July 16, 2011 at 1:45 am | Permalink

    Thanks alot, very good tutorial

2 Trackbacks

  1. [...] Welcome, one and all, to the second installment of actual code examples for the Conservative Design series. The decision was made (by me) to rename the component in question from the original Hierarchical Select to Hierarchical Options, due to the fact that the hierarchy can consist of any multiple option component, and is not limited to just a select. And to this face, this particular component was documented in the original post entitled Conservative Design: Hierarchical Select Boxes. [...]

  2. By TechRoam on June 21, 2007 at 11:53 am

    Auto-populating Select Boxes with AJAX and MYSQL…

    Chained Select Boxes Connected to a Database
    I am currently working on feature for a website that requires browsing throught the database with select boxes. Ebay uses select boxes for categorization (see image below) and this is pretty much what I nee…