PDA

View Full Version : Collapse javascript menu problem: menu goes to it's original setup after clicking ite



brecht27
11-20-2011, 09:54 PM
I have a collapse javascript menu but if i go to the first menu for example, the menu goes to his original setup (hide all) on the referring page. Can anyone help me to change the code so it 'remember' his previous choice?

Here is the code (without the css file)



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<script type="text/javascript">




<!--
window.onload=show;
function show(id) {
var d = document.getElementById(id);
for (var i = 1; i<=10; i++) {
if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
}
if (d) {d.style.display='block';}
}

//-->
</script>



<dl id="menu">




<dt onclick="javascript:show('smenu1');"><a href="#" onMouseOver="document.Image6.src='images/load-butt-rollover.gif';" onMouseOut="document.Image6.src='images/load-butt.gif';"><img src="images/load-butt.gif" name="Image6" width="197" border="0" id="Image6" /></a>
</dt>
<dd id="smenu1">
<ul>
<li><a href="test1.html">Test1 </a></li>
</ul>
</dd>

<dt onclick="javascript:show();"><a href="wheel.html" onMouseOver="document.Image7.src='images/wheel-butt-rollover.gif';" onMouseOut="document.Image7.src='images/wheel-butt.gif';"><img src="images/wheel-butt.gif" name="Image7" width="197" border="0" id="Image7" /></a></dt>

<dt onclick="javascript:show('smenu3');"><a href="#" onMouseOver="document.Image8.src='images/Gurd-butt-roll.gif';" onMouseOut="document.Image8.src='images/Gurd-butt.gif';"><img src="images/Gurd-butt.gif" name="Image8" width="197" border="0" id="Image8" /></a></dt>
<dd id="smenu3">
<ul>
<li><a href="test2.html">Test2 </a></li>
</ul>
</dd>
</dl>
</body>
</html>