spacer

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

home / web / dev / menus / oneformv2 To page 1To page 2current pageTo page 4To page 5To page 6
[previous] [next]

URPM: Single Form Version II

Developer News
Mandrake Linux Founder Back, Virtually
Amazon: We're a Technology Company
Sun Expands MySQL With Closed Source

Script Changes

It didn't take much work to fit the script to the new arrays. All that was required was to check for the presence of an array in the initLists() function by testing to see if the data type is an object. If it is, I call the O (Object) constructor with both a text and a value argument, otherwise, I substitute a null for the value, as in the old version:

    for(var i=0; i<a.length;i++) {
      if (a[i].length) {
        //create a new Option with the appropriate submenu
        subMenu = arg == argLen ? null : m[oldSubI++];
        temp[temp.length] = typeof(a[i])== "object"  ?
                            new O(a[i][0], a[i][1], subMenu ) :
           	            new O(a[i] ,   null ,   subMenu ); 
      }
      else
      { ...
       

I made up the system of storing the list contents in individual arrays because I had a lot of difficulty dealing with a giant array of "O" Objects. While my system worked well for me, it did not make it any easier on others, like I thought it would. A few people who wrote asked me if I could go over how this works, so I will start over and see if I can't clarify things a bit here.

There are a total of 4 arrays declared at the top of the old vs. new array example presented on the previous page. The m array is used to store the final list linking information, and the other three are for each listbox. You don't have to intertwine the arrays for the script to work, but I laid them out that way so that I can easily see which items in one list correspond to which subcategories in the next list. The easiest way to go about setting up the arrays is to start with the base list. Start with an array index of 0 and set each menu item from start to finish (see Step 1 below). Now that you've got your base list, insert all the relevant subcategories between each entry, without indexes (see Step 2). In my example, it's the model. Once you've done this, add an empty array element after the last subcategory (see Step 3a) and add the indexes, again starting from 0 (see Step 3b). The empty element is what tells the script to start a new subcategory. Then repeat the same process for all subcategories (see Step 4). When you're done, you should have the same kind of layout as on the previous page.

Step 1: construct the base list

manufacturer[0]=["ACURA", "ACU"];
manufacturer[1]=["ALFA ROMEO", "AR"];
...

Step 2: Add the subcategories

manufacturer[0]=["ACURA", "ACU"];
  model[]="CL";   //no value
  model[]="EL";
  model[]=["INTEGRA", "INT"];
manufacturer[1]=["ALFA ROMEO", "AR"];
  model[]=["SEDAN LS", "SLS"];
  model[]=["SPIDER", "SPI"];
...

Step 3a: Insert an empty array after each subcategory group

manufacturer[0]=["ACURA", "ACU"];
  model[]="CL";   //no value
  model[]="EL";
  model[]=["INTEGRA", "INT"];
  model[]=[];
manufacturer[1]=["ALFA ROMEO", "AR"];
  model[]=["SEDAN LS", "SLS"];
  model[]=["SPIDER", "SPI"];
  model[]=[];
...

Step 3b: Insert indexes, starting form 0

manufacturer[0]=["ACURA", "ACU"];
  model[0]="CL";   //no value
  model[1]="EL";
  model[2]=["INTEGRA", "INT"];
  model[3]=[];
manufacturer[1]=["ALFA ROMEO", "AR"];
  model[4]=["SEDAN LS", "SLS"];
  model[5]=["SPIDER", "SPI"];
  model[6]=[];
...

Step 4: Repeat steps 2 and 3 for each subcategory

manufacturer[0]=["ACURA", "ACU"];
  model[0]="CL";   //no value
   level[0]=["2.2 PREMIUM", "2.2"];
   level[1]="2.3";
   level[2]="3.0";
   level[3]=[];    //"" still works too
  model[1]="EL";
   level[4]=["PREMIUM", "PRE"];
   level[5]="SE";
   level[6]=["SPORT", "SP"];
   level[7]=[];
  model[2]=["INTEGRA", "INT"];
   etc...
  model[3]=[];
manufacturer[1]=["ALFA ROMEO", "AR"];
  model[4]=["SEDAN LS", "SLS"];
   etc...
  model[5]=["SPIDER", "SPI"];
   etc...
  model[6]=[];
...

home / web / dev / menus / oneformv2 To page 1To page 2current pageTo page 4To page 5To page 6
[previous] [next]

Written by Robert Gravelle and

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

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

Whitepapers and eBooks

Intel Whitepaper: Comparing Two- and Four-Socket Platforms for Server Virtualization
IBM Solutions Brief: Go Green With IBM System xTM And Intel
HP eBook: Simplifying SQL Server Management
IBM Contest: Are You the Next Superstar? Join the "Search for the XML Superstar" Contest to Find Out
Microsoft PDF: Top 10 Reasons to Move to Server Virtualization with Hyper-V
Microsoft PDF: Six Reasons Why Microsoft's Hyper-V Will Overtake Vmware
Microsoft Step-by-Step Guide: Hyper-V and Failover Clustering
Intel PDF: Quad-Core Impacts More Than the Data Center
Intel PDF: Virtualization Delivers Data Center Efficiency
Go Parallel Article: PDC 2008 in Review
Microsoft PDF: Top 11 Reasons to Upgrade to Windows Server 2008
Avaya Article: Communication-Enabled Mashups: Empowering Both Business Owners and IT
Intel Whitepaper: Building a Real-World Model to Assess Virtualization Platforms
  PDF: Intel Centrino Duo Processor Technology with Intel Core2 Duo Processor
Microsoft Article: Build and Run Virtual Machines with Hyper-V Server 2008
Go Parallel Article: Q&A with a TBB Junkie
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Internet.com eBook: Real Life Rails
IBM eBook: The Pros and Cons of Outsourcing
Internet.com eBook: Best Practices for Developing a Web Site
IBM CXO Whitepaper: The 2008 Global CEO Study "The Enterprise of the Future"
Avaya Article: Call Control XML in Action - A CCXML Auto Attendant
IBM CXO Whitepaper: Unlocking the DNA of the Adaptable Workforce--The Global Human Capital Study 2008
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
HP eBook: Guide to Storage Networking
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
webref The latest from WebReference.com Browse >
Popular JavaScript Framework Libraries: An Overview - Part 3 · Accessing Your MySQL Database from the Web with PHP · Working with the DOM Stylesheets Collection
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Crucial Triples Up With New Three-Channel DDR3 Kits · Meet the Finalists: Excellence in Technology Awards · Tealeaf Offers Insight to Mobile Customer Behavior

Created: October 2, 2001
Revised: October 2, 2001


URL: http://webreference.com/dev/menus/oneformv2/3.html