JavaScript Code

Show/Hide boxes for websites

Functions

<SCRIPT TYPE="text/javascript">
//This code does not work on netscape 4
function toggleButtons(srcElement, srcArrow) {
if (document.getElementById(srcElement).style.display == "none") {
document.getElementById(srcElement).style.display = "";
document.getElementById(srcArrow).src= "expand.gif";
}
else {
document.getElementById(srcElement).style.display = "none"
document.getElementById(srcArrow).src = "collapse.gif";
}
}


function writeExpandButton(tableId) {
if (!document.getElementById) return; // nothing in NN4
document.writeln('<A HREF="javascript:toggleButtons(\''+tableId+'\',\'img_'+tableId+'\')"><IMG ID="img_'+tableId+'" SRC="expand.gif" BORDER="0" align="left"></A>');
}
</SCRIPT>
 

How to use?

1) call  writeExpandButton(div name) to draw the button and pass the <DIV>'s name to show and hide:

<SCRIPT>writeExpandButton('divname1');</SCRIPT>
 

2) put the part to hide/show into a div and give it the name given to the function above:

<DIV ID="divname1">
 

<!-- .... part to hide and show -->

</DIV>

 

 

 

home

1