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.
Next: The remove2NumID() Function Details >>
More HTML Articles
More By Chrysanthus Forcha