Hello guyz,
am testing the following javascript
(its a kind of JS-menu) and works all right, but i want to get something more..
If i click ones, (par example) on
,
i will get :
Quote:
menu sub item
menu sub item
menu sub item
menu sub item
menu sub item
menu sub item
|
But,, if i try to click on
again,
then nothing will happend

..and the :
Quote:
menu sub item
menu sub item
menu sub item
menu sub item
menu sub item
menu sub item
|
..will not appear
..this is what i want to solve, so when i click on "menu item 1" , "menu item 2" , " menu item 3 " again after ones to work like before the fist time .
Please help me to do this,
thanks
Code:
<html>
<head>
<title>js test</title>
<script>
var p = 0;
function show_mnu(id){
var e = document.getElementById(id);
e.style.display = 'block';
hide_mnu(id);
p = id;
}
function hide_mnu(id){
if(p != 0){
var e = document.getElementById(p);
e.style.display = 'none';
}
}
</script>
</head>
<body>
<table>
<tr>
<td width="125px" valign="top" nowrap>
<a href="javascript:void(0);" onClick="show_mnu('mnu_top_01')">menu item 1</a><br />
<div id="mnu_top_01">
<span>menu sub item</span><br />
<span>menu sub item</span><br />
<span>menu sub item</span><br />
<span>menu sub item</span><br />
<span>menu sub item</span><br />
<span>menu sub item</span><br />
</div>
<a href="javascript:void(0);" onClick="show_mnu('mnu_top_02')">menu item 2</a><br />
<div id="mnu_top_02">
<span>menu sub item</span><br />
<span>menu sub item</span><br />
<span>menu sub item</span><br />
<span>menu sub item</span><br />
<span>menu sub item</span><br />
<span>menu sub item</span><br />
</div>
<a href="javascript:void(0);" onClick="show_mnu('mnu_top_03')">menu item 3</a><br />
<div id="mnu_top_03">
<span>menu sub item</span><br />
<span>menu sub item</span><br />
<span>menu sub item</span><br />
<span>menu sub item</span><br />
<span>menu sub item</span><br />
<span>menu sub item</span><br />
</div>
</td>
</tr>
</table>
</body>
</html>