spacer

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

home / web / dev / menus / intro2

Another Way

Java Software Engineer / Architect Sr (IL)
Next Step Systems
US-IL-Chicago

Justtechjobs.com Post A Job | Post A Resume
Developer News
OpenOffice 3.2 Lands Amid Critical Changes
Red Hat, IBM Firmly in KVM Virtualization Camp
Red Hat Talks Up Open Source Cloud Plans


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



The Network for Technology Professionals

Search:

About Internet.com

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

webref The latest from WebReference.com Browse >
Search Engine Optimization: Selecting and Embedding Keywords · Are Google's Language Translation Web Services Ready for Prime Time? · Installing and Using Meeplace, the Business Review CMS
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
IBM DB2 10 for z/OS: Justifying the Upgrade · Living La Vida Colo: Choosing the Right Colocation Facility · FTC Concerns over Social Media Privacy Linger



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

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