Home arrow HTML arrow Page 4 - Functions for a Menu for All Browsers
HTML

Functions for a Menu for All Browsers


Welcome to the fifth part of a nine-part series that will show you how to build a browser menu. The aim of this series is to come up with a menu code that you can use with the majority, if not all, browsers without taking the particularities of a browser into consideration. We spent significant time on the previous parts on the layout; now we will get down to the code.

Author Info:
By: Chrysanthus Forcha
Rating: 5 stars5 stars5 stars5 stars5 stars / 2
June 03, 2009
TABLE OF CONTENTS:
  1. · Functions for a Menu for All Browsers
  2. · Names of the Functions and their Roles
  3. · The dropDownMenu() Function Details
  4. · The remove3NumID() Function Details
  5. · The remove2NumID() Function Details

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Functions for a Menu for All Browsers - The remove3NumID() Function Details
(Page 4 of 5 )

Let us talk about the remove3NumID() function and then the remove2NumID() function before we talk about the react() function. The remove3NumID() function removes any sub menu whose number part of the table ID is made up of three digits. This is the function:


function remove3NumID()

{

for (i=0;i<5;i++)

{

for (j=0;j<5;j++)

{

for (k=0;k<5;k++)

{

//form ID

theID = 'ST' + i + j + k;

if (document.getElementById(theID))

{

document.getElementById(theID).style.visibility = "hidden";

document.getElementById(theID).style.display = "none";

}

}

}

}

}



This function is called only under special circumstances. There are three for-loops. Each for-loop is for one digit. Each for-loop iterates from the index number zero to the index number 4. These five iterations are for the maximum of five menu items that our example can have for a sub menu. All the statements are in the innermost for-loop.

IDs of all possible three-digit combinations for our example are formed as the program goes through the three for-loops, from index zero to 4. The first statement in the inner for-loop forms the ID. The next statement first checks if that ID exists (for our example). If it does, then two statements are executed. The first of the two statements gives a value of "hidden" to the visibility property of the corresponding table. The second statement removes the table by giving the value of "none" to the display property of the table.

The first statement (hidden) is not really necessary. However, if you do not have it, Internet Explorer may not remove the table. The other browsers do not need the statement.


blog comments powered by Disqus
HTML ARTICLES

- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5
- BBC Adopts HTML 5, Mozilla Addresses Issues
- Advanced Sticky Footers in HTML and CSS
- HTML and CSS Sticky Footers
- Strategy Analytics Predicts HTML5 Phones to ...
- HTML5 Guidelines for Web Developers
- Learning HTML5 Game Programming
- More Engaging CSS3 and HTML Background Effec...
- Engaging HTML and CSS3 Background Effects
- More Web Columns with CSS3 and HTML
- Columns with CSS3 and HTML
- Creating Inline-Block HTML Elements with CSS
- Drag and Drop in HTML5: Parsing Local Files

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 11 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials