JavaScript Examples

JavaScript Menu

Home

 



 
 

  

Dynamically updated drop down box
(data in 3-dimensional array)

Car Year: 

Car Make: 

Car Model: 


This example shows how to dynamically update drop down boxes with a little twist. The data about the makes and models of cars for a particular year is stored in a 3-dimensional array. If this page were dynamically generated, this array could be generated on the fly from the data in the database.

NOTE: In some versions of Netscape browsers, the size of the combo box will not change dynamically to accommodate for the larger or smaller size of options. That is the box will not become wider if options require more space. IE automatically updates the size of the component.With Netscape there are two options. First is to find the width of the longest option and to put extra spaces into the text of the initial option, so that it will take as much space as the largest option. This way, we will be guaranteed that the largest option will still have enough space. Second option is to include an update statement "history.go(0)", which will reload the page and re-size the component.