HTML
  Home arrow HTML arrow Page 3 - 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 toChoose() Function


    (Page 3 of 4 )

    One of the objectives of the code is that, when you do not want to see any drop down or sub menu, you should click the BODY element outside the drop down or sub menu. When you do this, any drop down menu or sub menus on the screen should be removed.

    However, when you click a menu item in the drop down or sub menu, you do not want the drop down menu or sub menu to be removed. Whenever you click the menu item, the BODY element indirectly receives a click. This indirect click is supposed to remove the drop down or sub menus.

    To prevent this, we have to use the toChoose() function. The toChoose() function is called whenever you click a cell of the drop down menu or sub menu. When you click any of these cells, this function is called before the BODY element receives the indirect click. This function name is the value of the onclick attribute for any of these cells.

    The function takes the ID of the cell as an argument. It sets the subMenuJustClicked global variable to true. The function called when the BODY element receives a click, either directly or indirectly, first checks to see if this variable is false. If it is false, it removes the drop down or sub menus; if it is true, it does not remove them. This is the toChoose() function:


    var subMenuJustClicked = false; //for removing sub menus


    function toChoose(ID)

    {

    currCellBgColor = document.getElementById(ID).style.backgroundColor; //background color of the current cell

     

    if ((currCellBgColor == "firebrick")||(currCellBgColor == "#b22222")||(currCellBgColor == "rgb(178, 34, 34)"))

    subMenuJustClicked = true;

    }


    The function uses the only global variable, subMenuJustClicked. This is the only global variable in the code. This function has just one main statement, which is an if-statement. The condition of this if-statement is the only code segment that really addresses the particular needs of different browsers. So this is the code segment I have been talking about that really addresses peculiarities of different browsers. Fortunately it is a very short code segment. You can think of it as a one-line code segment.

    Before we look at the particular issues addressed, let us see what the function does. The if-state checks to see if the background color of the cell the mouse pointer is on, is firebrick. If it is firebrick, it sets the  subMenuJustClicked global variable to true. The statement before this if-statement in the function retrieves the background color of the cell.

    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 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek