473,394 Members | 1,287 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Adding new level to simple "tree" menu

http://dynamicdrive.com/dynamicindex1/switchmenu.htm

I want to add a second level menu item to the existing design.
Currently only one level is possible.

Item 1
......link
......link
item 2
item 3
item 4

I want to show....

item 1
.....item 1a
.....item 1b
.....item 1c
.........link
.........link
item 2

So that when item 1a is clicked, only those items in that division are
collapsed.

I am assuming I can simply add a new variable, say "var item1" then copy the
script for the changes, and change "masterdiv" to "item1".

Or if anyone has a link to a similar layout with multiple layers I'll take a
look at it.

if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}

function SwitchMenu(obj){
if(document.getElementById){
var el = document.getElementById(obj);
var ar = document.getElementById("masterdiv").getElementsBy TagName("span");
//DynamicDrive.com change
if(el.style.display != "block"){ //DynamicDrive.com change
for (var i=0; i<ar.length; i++){
if (ar[i].className=="submenu") //DynamicDrive.com change
ar[i].style.display = "none";
}
el.style.display = "block";
}else{
el.style.display = "none";
}
}
}
Jul 23 '05 #1
1 2744
Richard wrote:
http://dynamicdrive.com/dynamicindex1/switchmenu.htm I want to add a second level menu item to the existing design.
Currently only one level is possible. Item 1
.....link
.....link
item 2
item 3
item 4 I want to show.... item 1
....item 1a
....item 1b
....item 1c
........link
........link
item 2


Ok so my first attempt went so so.
When page is first opened it shows.....

item 1
.....item 1a
.........link
item 2
item 3

When link is clicked on I get...

item 1
......item 1 a
item 2
item 3

When item 1a is clicked, the original tree shows and nothing else happens
anywhere.
So what do I need to do to correct so I get what I want?

My changes are below.
function SwitchMenu(obj){
if(document.getElementById){
var el = document.getElementById(obj);
var ar = document.getElementById("masterdiv").getElementsBy TagName("span");
//DynamicDrive.com change
if(el.style.display != "block"){ //DynamicDrive.com change
for (var i=0; i<ar.length; i++){
if (ar[i].className=="submenu") //DynamicDrive.com change
ar[i].style.display = "none";
}
el.style.display = "block";
}else{
el.style.display = "none";
}

var item1 =
document.getElementById("master2").getElementsByTa gName("span");
//DynamicDrive.com change
if(el.style.display != "block"){ //DynamicDrive.com change
for (var i=0; i<item1.length; i++){
if (item1[i].className=="submenu2") //DynamicDrive.com change
item1[i].style.display = "none";
}
el.style.display = "block";
}else{
el.style.display = "none";
}
}
} // end of function
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jo | last post by:
I don't know if this can be done.. But here is what i am trying to do... I have a tree menu on a frameless page. I have the menu on the right hand side and a CGI web form post on the left....
4
by: erikd | last post by:
I'm using an expanding tree menu based on the design from Dieter Bungers GMD (www.gmd.de) and infovation (www.infovation.de) named displayToc.js. The problem is that the script isn't working...
6
by: Dennis Allen | last post by:
Hi. I was wondering if someone here could help me. My web site has a very simple folder tree menu bar. Example: <a id="club_t" href="##" onclick="return Outline(this)"><img id="club_i" alt=""...
2
by: Angelos | last post by:
Hello there.. I have the folowing piece of javascript that hides all my ul elements in a menu of the folowing structure: <ul> <li><a href="#">Page</a> <ul> <li><a href="#">Add</a></li> <li><a...
18
by: Andromeda | last post by:
I've been trying to add a tree menu to my website with some luck (more or less). I came across a script on simplythebest.net, but I seem to be having a problem with it... and since they have no...
0
by: Tree menu using XML | last post by:
I have one XML file that has nodes and sub node and each and every node has the attribute call visible if its value is true then diplay this node else don't display thid node, but this condition i...
3
by: lejason | last post by:
I am trying to make a tree menu that is similar to this http://genieindustries.com/service_manuals.asp where you can click an list item and it will un-hide another list. It seems simple...
0
by: preetkanwal0678 | last post by:
Hello all, Am working on PYTHON +BRANWAVE(framework) Actually am Trying 2 make a tree menu using d both. Am not able 2 target the (.tmpl) files and not getting how 2 make frames in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.