Functions for a Menu for All Browsers - The remove2NumID() Function Details
(Page 5 of 5 )
The remove2NumID() function removes any sub menu whose number part of the table ID is made up of two digits. This is the function:
function remove2NumID()
{
for (i=0;i<5;i++)
{
for (j=0;j<5;j++)
{
//form ID
theID = 'ST' + i + j;
if (document.getElementById(theID))
{
document.getElementById(theID).style.visibility = "hidden";
document.getElementById(theID).style.display = "none";
}
}
}
remove3NumID()
}
This function is called only under special circumstances. There are two 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 of the statements are in the innermost for-loop.
IDs of all possible two-digit combinations for our example are formed as the program goes through the two 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.
Now, notice that before the end of this function, the remove3NumID() function is called. The remove2NumID() function is normally called when you want to remove tables whose number parts are made up of two or three digits. So after the tables whose number parts are made up of two digits are removed, the remove3NumID() function is called to remove the tables whose number parts are made up of three digits.
Note this: if you have sub menus of lower levels (four digit number parts, five digits, etc.) then you would need functions such as remove4NumID(), remove5NumID(), etc. for removing the corresponding tables. The remove4NumID() function will have four for-loops, remove5NumID() will have five for-loops, etc.
Let us take a break here. We continue in the next part with the react() function.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |