Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Collapsible menu with different levels.

Status
Not open for further replies.

celia01es

Programmer
May 17, 2007
7
ES
Hi,
I would like to have the following collapsible menu (with different levels):

Initial menu:
- TITLE 1

- TITLE 2

Then clicking on TITLE 1
- TITLE 1
TITLE 1.1
TITLE 1.2

- TITLE 2

Then clicking on TITLE 1.1
- TITLE 1
TITLE 1.1
TITLE 1.1.1 => link to a jsp file
TITLE 1.1.2 => link to a jsp file

TITLE 1.2

- TITLE 2

Clicking on TITLE 2
- TITLE 1

-TITLE 2
TITLE 2.1 => link to a jsp file
TITLE 2.2 => link to a jsp file

I have a javascript that I have been using but if works for 2 levels and I need 3 levels.... I am sure it is not that difficult but I simply don't know how to do it. When I try something it never works.
Could you help me modify my script?

Thanks


Here is my script:
Code:
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="style.css">
<style type="text/css">
<!--
#menu {
    position:relative;
     font-family: Arial, Helvetica, sans-serif;
    width:400px;
}
-->
</style>
<%@ include file="javascriptLib.html" %>
<script language="JavaScript" type="text/JavaScript">
<!--- oculta el script para navegadores antiguos
var origValue=null;
var fieldIndex=null;

if (self.location != top.location)
{
//  top.location = self.location;
}


subcol='white';//El bgcolor de los sub-enlaces
indent=20;//La indentacion a la izquierda en pixels

function coll()
{
var dd=document.getElementById('menu').getElementsByTagName('div');
for (var i=1;i<dd.length;i=i+2)
{
  dd[i].style.position='relative';
  dd[i].style.display='none';
  dd[i].style.backgroundColor=subcol;
  dd[i].style.left=indent+'px';
}
}

function activ(w)
{
var d=w.parentNode.getElementsByTagName('div')[0];
if(d.style.display=='none')
{
  coll();d.style.display='inline';
}
else
{
  d.style.display='none';
}
}

onload=coll();
// end hiding from old browsers -->

</script>
</head>
<body onload=coll()>
<!-- Menu -->
<div id="menu" style="width:100%; margin:auto;">
<bl>
<div>
  <li><a href="#" id="L1" onclick="activ(this)">TITLE1</a><br>
      <div>
        <a href="#" onclick="activ(this)">TITLE1.1</a><br>
      </div>
</div>
<br>

<div>
  <li>
   <a href="#" onclick="activ(this)">TITLE2</a><br>
       <div>
         <a href="foo1.jsp">- TITLE2.1</a><br>
         <a href="foo2.jsp">- TITLE2.2</a><br>
       </div>
</div>
</bl>
</div>
<!-- END Menu -->
</body>
</html>
 
I have looked at lot of places but none of them solve my problem. I need to know the correct syntax for the collapsible menu in order to modify it with jsp.
Please, help me.
 
Why re-invent the wheel? This has been done thousands of other times and there are lots of tutorials online on how to achieve multitiered dropdowns, Suckerfish probably being the most popular.

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson
 
THanks for the link,..... but the thing is that I would like to modify what I already have. COuld you help me modify it so it does what I want?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top