React and ToChoose Functions for a Menu for All Browsers
(Page 1 of 4 )
Welcome to the sixth part of a nine-part series that shows you how to build a menu for all browsers. In this part we continue to take a look at the JavaScript functions, specifically the react() and toChoose() functions.
The react() Function Details
The arguments for this function are not really the ones we saw in the previous series. This function is called when the mouse pointer goes over a drop down menu or sub menu item. Each of the cells for these items has an onmouseover event attribute. One of attributes is:
onmouseover = "react('TD11','1','sub','5')"
Now let us look at the function. Here it is:
function react(ID,colNo,submenu,noRows)
{
//first make sure all background colors of the sub menu cells are brown.
for (i=0; i<noRows; i++)
{
//form the ID
theID = "TD" + i + colNo;
document.getElementById(theID).style.backgroundColor = "brown";
}
//let the background of the current sub menu cell be firebrick.
document.getElementById(ID).style.backgroundColor = "firebrick";
//remove any lower sub menu that was displayed before you display the new one
if (ID.length == 4)
remove2NumID();
else if (ID.length == 5)
remove3NumID()
//display sub menu
if (submenu == "sub")
{
//ID of sub table
beginslice = 2;
endslice = ID.length;
slicedStr = ID.slice(beginslice,endslice);
IDSUB = 'ST' + slicedStr;
document.getElementById(IDSUB).style.display = "block";
document.getElementById(IDSUB).style.visibility = "visible";
}
}
Next: The Parameters of the react() function >>
More HTML Articles
More By Chrysanthus Forcha