Forum Moderators: open
JavaScript:
function collapseAll(objs) {
var i;
for (i=0;i<objs.length;i++ ) {
}
}
function pageLoad() {
collapseAll($('myDiv1','myDiv2','myDiv3'));
}
addEvent(window,'load',pageLoad); HTML:
<a onclick="switchMenu('myDiv1');">Expand/Collapse</a>
<div id="myDiv1">
Material that is to be expanded/collapsed.
</div>
function ShowTab(tab,id){ // tab is an array, id is the div's name/id.
var array_length = tab.length; // Get's the length of the array
for(var i=0; i<array_length; i++){ // Loops through the array
var obj = document.getElementById(tab[i]).style; // Shorthand for the div's style
if(tab[i] == id){ // Checks to see which div is selected and sets the visibility
obj.visibility = 'visible';
}
else{
obj.visibility = 'hidden';
}
}
}