/    Sign up×
Community /Pin to ProfileBookmark

Collapse and expand a tree menu

Hello,

is there someone who can help me tot collapse and expand my menu? I have realy no idear how te fix this.
Here is the script of the menu:

<html>
<head>
<title>Navigatie Menu Intranet</title>
<link rel=”stylesheet” href=”menustyle.css” type=”text/css”>
<script language=”javascript” src=”tree.js”></script>
</head>

<body>

<table cellspacing=”0″ cellpadding=”0″ border=”0″ width=”159″>
<tr>
<td align=”center” valign=”top” style=”height: 112px; text-align: center; background-image: width=”159″>

<table width=”100%” border=”0″ cellpadding=”0″ cellspacing=”0″>
<tr>
<td style=”height:6px;”></td>
</tr>
<tr>
<td><div align=”center”></a>
<map name=”Map”>
<area shape=”poly” coords=”102,1,105,2,105,49,57,51,0,51,-3,25,54,25,55,3″>
<area shape=”poly” coords=”105,31,133,31,134,82,86,82,21,82,21,53,88,52,107,52,104,31″> </map>
</div></td>
</tr>
</table> </td>
</tr>
<tr>
<td width=”159″></td>
</tr>
<td bgcolor=”#FFDF1B” width=”159″>
<table border=0 cellpadding=’1′ cellspacing=1><tr><td width=’16’><div align=”right”></div></td><td>Home
</table>
<tr>
<td bgcolor=”#FFDF1B” width=”159″></td>
</tr>
<tr>
<td bgcolor=”#FFDF1B” width=”159″>
<table border=”0″ width=”161″ cellspacing=”1″ cellpadding=”1″>
<tr>
<td width=”16″><div align=”right”><a id=”xpersoneel” href=”javascript:Toggle(‘personeel’);”></a></div></td>
<td width=”131″><a id=”xpersoneel” href=”javascript:Toggle(‘personeel’);”>HOOFDTEST</a></td>
</tr>
</table>
</td>
</tr>
<td bgcolor=”#FFEB7A” width=”159″>
<div id=”personeel” style=”display: none; margin-left: 2em;”>
<table border=0 cellpadding=’1′ cellspacing=1><tr><td width=’16’><a id=”xsmoelenboek” href=”javascript:Toggle(‘smoelenboek’)</a></td><td><a href=”javascript:Toggle(‘smoelenboek’);”>TEST</a></table>
<div id=”smoelenboek” style=”display: none; margin-left: 2em;”>
<table border=0 cellpadding=’1′ cellspacing=1><tr><td width=’16’></td><td>SUBTEST</td></tr></table>
<table border=0 cellpadding=’1′ cellspacing=1><tr><td width=’16’></td><td>SUBTEST</td></tr></table>
<table border=0 cellpadding=’1′ cellspacing=1><tr><td width=’16’></td><td>SUBTEST</td></tr></table>
<table border=0 cellpadding=’1′ cellspacing=1><tr><td width=’16’></td><td>SUBTEST</td></tr></table>
</div>

<table border=0 cellpadding=’1′ cellspacing=1><tr><td width=’16’></td><td>TEST1</td></tr></table>
<table border=0 cellpadding=’1′ cellspacing=1><tr><td width=’16’></td><td>TEST2</td></tr></table>
<table border=0 cellpadding=’1′ cellspacing=1><tr><td width=’16’></td><td>TEST3</td></tr></table>
<table border=0 cellpadding=’1′ cellspacing=1><tr><td width=’16’></td><td>TEST4</td></tr></table>
<table border=0 cellpadding=’1′ cellspacing=1><tr><td width=’16’></td><td>TEST5</td></tr></table>
<table border=0 cellpadding=’1′ cellspacing=1><tr><td width=’16’></td><td>TEST6</td></tr></table>
</div>
<tr>
<td bgcolor=”#FFDF1B” width=”159″></td>
</tr>
<td bgcolor=”#FFDF1B” width=”159″>
<table border=0 cellpadding=’1′ cellspacing=1><tr><td width=’16’><div align=”right”></div></td><td>Sitemap
</table>
<tr>
<td bgcolor=”#FFDF1B” width=”159″></td>
</tr>
<tr>
<td width=”159″><div align=”left</div></td>
</tr>
</table>

</body>
</html>

Here is the script of the tree.js:

function Toggle(item) {
obj=document.getElementById(item);
visible=(obj.style.display!=”none”)
key=document.getElementById(“x” + item);
if (visible) {
obj.style.display=”none”;
key.innerHTML=”<img src=’folder.gif’ width=’6′ height=’6′ hspace=’0′ vspace=’0′ border=’0′>”;
} else {
obj.style.display=”block”;
key.innerHTML=”<img src=’textfolder.gif’ width=’6′ height=’6′ hspace=’0′ vspace=’0′ border=’0′>”;
}
}

function Expand() {
divs=document.getElementsByTagName(“DIV”);
for (i=0;i<divs.length;i++) {
divs[i].style.display=”block”;
key=document.getElementById(“x” + divs[i].id);
key.innerHTML=”<img src=’textfolder.gif’ width=’6′ height=’6′ hspace=’0′ vspace=’0′ border=’0′>”;
}
}

function Collapse() {
divs=document.getElementsByTagName(“DIV”);
for (i=0;i<divs.length;i++) {
divs[i].style.display=”none”;
key=document.getElementById(“x” + divs[i].id);
key.innerHTML=”<img src=’folder.gif’ width=’6′ height=’6′ hspace=’0′ vspace=’0′ border=’0′>”;
}
}

I hope that someone can help me with this menu.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@PittimannAug 06.2004 — Hi!

I don't really see your problem. Apart from the spaces, the software of these forums inserts between 'java' and 'script' when you type javascript, your code works. What aren't you satisfied with?

Cheers - Pit
Copy linkTweet thisAlerts:
@nikkiwalauthorAug 06.2004 — I want that the menu collapse when i'm open another button. I know I have only one menu here but when I go to another menu I whant that my first menu collapse. And now all the menu's must be collapst by hand.
Copy linkTweet thisAlerts:
@PittimannAug 06.2004 — Hi!

Just to know a bit more about what you want:

Imagine, TEST2 is currently expanded. Then HOOFDTEST is clicked and the stuff disappears. Would you want TEST2 to appear expanded when HOOFDTEST is clicked next time or do you want everything to be collapsed also when HOOFDTEST is clicked?

Cheers - Pit
×

Success!

Help @nikkiwal spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...