Software development stuff.

2005-05-19

Multiple dynamic combo-boxes in an HTML page

While answering this question at Experts Exchange I created this javacript that maintains a variable number of combo-boxes connected with each other all on the client-side. I'm sure many people have done this several times, and there are tons of different solutions for this. Mine is a good (IMHO) open solution with the following characteristics:
  • Any number of combos supported (tested with 2 and 3)
  • Per item description supported
  • Javascript function hook for the last combo
  • IE and Firefox compatible (not tested with other browsers)
  • Multiple instances of combo groups on the same page supported

The solution is here.

To use it, just save the source of the file. It's not difficult to understand the logic, look at the BODY part of the file. You need to set the following:

  • the SELECT tags with the extra attributes
  • the javascript array with MCComboItem's
  • the action function for the last combo
  • Invoke MCStart function passing the references to everything and the initial values for the combos.