spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / web / dev / menus / intro2

Another Way

Sr. Web Developer
mediabistro.com
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume
Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?


Universal Related Popup Menus

Another way to approach the code is to first fill a two-dimensional array and create the new options on the fly. This technique makes it easier to add new menu items, and also extend this technique to another dimension. Here's a stripped down version for download.

Choose a subject:
---> Choose a topic:

Related Select Lists

Choose a subject:
---> Choose a topic:

The menus work identically to the previous page, and degrade gracefully. The array creation code has gone 2-D and now pregenerates the menu array outside the relate function.


Can You Relate?

The relate function, which changes the second menu based on the first menu's selection, has been stripped of the on the fly array creation and now uses the 2-D array we created above to change the second menu's options on the fly.


The guts of the relate function remain the same with two changes. The second menu's options array are now filled on the fly with the new Option command referring to the text and value properties of the a[j][i] element of our 2-D array. The aln2=a.length kludge was also replaced by calculating the length of the selectedIndex element of the 2-D array a (the number of options to be overwritten on the second menu).

This technique of pregenerating our options array can be extended into another dimension to create three related menus.

The full redirect.cgi script is also available in text form.

Comments are welcome


internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business



Created: Mar. 9, 1997
Revised: July 22, 1999

URL: http://webreference.com/dev/menus/intro2.html