/**************************************************************************
*
* Function: toggleVis
*
* Description: Following Function hides and expands the main column.
*
*
***************************************************************************/
// Set the default "show" mode to that specified by W3C DOM
// compliant browsers
var showMode = 'table-cell';
// However, IE5 at least does not render table cells correctly
// using the style 'table-cell', but does when the style 'block'
// is used, so handle this
if (document.all) showMode='block';
// This is the function that actually does the manipulation
var States = { };
function toggleVis(col){
if (!States[col] || States[col].IsOpen == null)
{
States[col] = {isOpen : true}; // This assumes the cell is already shown
//States[col] = {isOpen : false}; // This assumes the cell is already hidden
}
//mode = States[col].IsOpen ? showMode : 'none';
mode = States[col].IsOpen ? 'none' : showMode; //starts from closed, next click need open
cells = document.getElementsByName(col);
for(j = 0; j < cells.length; j++) cells[j].style.display = mode;
States[col].IsOpen = !States[col].IsOpen;
}
This function hides and displayed a column for a html table. When I call this function the object States toggles accordingly, true if expanded, false if hidden or none. After the function is executed once, what saves the last state of States so that it can be used in this function, when called again? Is it because the object States{} is declared as a global?