HTML
  Home arrow HTML arrow Page 2 - React and ToChoose Functions for a Menu fo...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
HTML

React and ToChoose Functions for a Menu for All Browsers
By: Chrysanthus Forcha
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 2
    2009-06-10

    Table of Contents:
  • React and ToChoose Functions for a Menu for All Browsers
  • The Parameters of the react() function
  • The toChoose() Function
  • The toChoose() Function Continued

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    React and ToChoose Functions for a Menu for All Browsers - The Parameters of the react() function


    (Page 2 of 4 )

    The first parameter, ID, is for the ID of the cell on which the mouse pointer is sitting. If the mouse pointer is sitting on a cell that is in a drop down menu, then the second parameter, colNo, is the column number of the main table with the drop down menu. If the cell is in a sub menu, then colNo is the number part of the ID of the Table (nesting) with the sub menu.

    The submenu parameter can take the word "sub" or be empty. If the onclick attribute (calling function) has the word "sub" for this argument, it means that the cell has the character ‘>’ and should give rise to a sub menu. So, when the react() function sees "sub" it knows that it has to produce a corresponding sub menu.

    The last parameter, noRows, is the number of menu items (rows) of the sub menu that have the cell on which the mouse pointer is sitting, not the number of menu items of the sub menu to be generated.

    The Statements of the react() Function

    The react() function first of all makes sure the background colors of all the cells of the table are brown. It uses a for-loop and the ID of the cell that triggered the event for this. The noRows parameter gives us the number of iterations. The first statement in the for-loop forms the ID of the current cell using the iteration index and the colNo argument. The next statement in the for-loop gives the brown color.

    The statement after the for-loop gives the firebrick color to the background of the cell on which the mouse pointer is sitting. With this process, only one cell in a table will always have the firebrick color.

    Next we have an if-else-if statement. If the length of the ID of the cell that triggered the event (called the react() function) is four characters, then the number part of the ID has two digits. It means the cell is in a drop down menu. So any sub menu has to be removed. In our example, the sub menus are of two different levels. For the first level, the number part of the table ID has two digits. For the second level, the number part of the table ID has three digits.

    The if-statement checks if the length of the ID of the cell that triggered the event is 4 characters. If it is, it calls the remove2NumID() function, which will in turn call the remove3NumID() function. In that way, any table whose ID has a number part equal to or greater than 2 digits will be removed. 

    The else-if part checks if the length of the ID is 5 characters long. If this is the case, it means that the number part of the ID has three digits. It means the cell is in a first level sub menu. So any second level sub menu has to be removed. This is done by calling the remove3NumID() function. With this process, any unwanted sub menu that was previously displayed is removed. If any previous sub menu is to be re-displayed, then that will be achieved by the next statement in the react() function.

    The next statement displays the sub menu if, in the call of the react() function, the third argument is "sub." We have an if-statement here. The if-statement tests to see if the argument is "sub." If it is, then the relevant sub menu is displayed by executing the statements in the block of the if-statement.

    In the block, the ID of the table to be displayed has to be formed. The ID of this table begins with "ST." The number part of this ID is the same as the number part of the cell that triggered the event. In order to get the number part of this cell, we use the JavaScript "slice" method of the string object.

    The first statement in the if-block declares the variable for the value where slicing will begin. The ID is a string; it begins with "TD." So slicing has to begin at the index value of 2. So 2 is assigned to this variable. After the "TD" characters of the cell ID, the rest of the characters are digits. So slicing has to end at the end of the ID (string). The second statement of the block declares a variable for this and assigns the length of the ID string to it.

    The next statement in the block does the slicing and assigns the returned number to the slicedStr variable. The next statement forms the ID of the table (nesting) to be displayed. The statement after that displays the sub menu table.

    Now the last statement sets the value of the visibility property of the displayed sub menu table to "visible." This statement is only obligatory if you used the "hidden" statement in the places we mentioned before.

    More HTML Articles
    More By Chrysanthus Forcha


     

    HTML ARTICLES

    - Comparing Browser Response to Active Client ...
    - Testing Browser Response to Active Client Pa...
    - Active Client Pages: Completing the Code for...
    - ACP and Browsers: Setting up an Example
    - How Browsers Respond to Active Client Pages
    - Completing a Tree with Active Client Pages
    - HTML Form Verification and ACP
    - Building an ACP Tree
    - Completing an ACP 3D HTML Table Image Gallery
    - Building an ACP 3D HTML Table Image Gallery
    - A Multiple Page Image Gallery with Active Cl...
    - Building an Image Gallery with Active Client...
    - Concluding a Menu for All Browsers
    - A Vertical Menu for All Browsers
    - Downloading Long HTML Pages with ACP







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek