473,663 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.getEl ementById){ //DynamicDrive.co m change
document.write( '<style type="text/css">\n')
document.write( '.submenu{displ ay: none;}\n')
document.write( '</style>\n')
}

function SwitchMenu(obj) {
if(document.get ElementById){
var el = document.getEle mentById(obj);
var ar = document.getEle mentById("maste rdiv").getEleme ntsByTagName("s pan");
//DynamicDrive.co m change
if(el.style.dis play != "block"){ //DynamicDrive.co m change
for (var i=0; i<ar.length; i++){
if (ar[i].className=="su bmenu") //DynamicDrive.co m change
ar[i].style.display = "none";
}
el.style.displa y = "block";
}else{
el.style.displa y = "none";
}
}
}
Jul 23 '05 #1
1 2753
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.get ElementById){
var el = document.getEle mentById(obj);
var ar = document.getEle mentById("maste rdiv").getEleme ntsByTagName("s pan");
//DynamicDrive.co m change
if(el.style.dis play != "block"){ //DynamicDrive.co m change
for (var i=0; i<ar.length; i++){
if (ar[i].className=="su bmenu") //DynamicDrive.co m change
ar[i].style.display = "none";
}
el.style.displa y = "block";
}else{
el.style.displa y = "none";
}

var item1 =
document.getEle mentById("maste r2").getElement sByTagName("spa n");
//DynamicDrive.co m change
if(el.style.dis play != "block"){ //DynamicDrive.co m change
for (var i=0; i<item1.length ; i++){
if (item1[i].className=="su bmenu2") //DynamicDrive.co m change
item1[i].style.display = "none";
}
el.style.displa y = "block";
}else{
el.style.displa y = "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
5839
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. When i Post a form and it displays a new html page i would like to see a different branch expaned on the tree menu and close (who be a bonus) the other one that is open.
4
2683
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 properly in Firefox, although it's working without problems in IE 5.5 & 6.0 In Firefox any file which isn't in the same directory isn't found, so the images are missing and the links don't launch. It may be something simple, but I don't have the...
6
2726
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="" border="0" src="fold.gif">Club&nbsp;Links</a><br> <div id="club_s" class="off"> <a href="articles.htm" target="main">Articles/Cartoons</a><br> <a href="photo1.htm" target="main">Astro&nbsp;Images</a><br> <a href="links.htm"...
2
3052
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 href="#">List</a></li> </ul> </li> <li><a href="#" >News</a>
18
3532
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 help section, this has brought me here. The script can be found at http://simplythebest.net/scripts/DHTML_scripts/dhtml_script_100.html (no login or anything required... I just thought the script might be too long to repost here)
0
2175
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 am able to check using xpath in asp.net 2.0 till MenuItem node. if i check visible attribute value till SubMenuLevel0 node then in tree it will not display the MenuItem Node at all Note: My tree Menu will start from MenuItem node and it will...
3
2384
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 enough...but when I try it here http://www.wcumc.org/wcumc/w/content.php?type=info it works in reverse. Meaning, it starts with the list fully expanded and then by clicking on the parent, it collapses. So, how do I get it to start closed and then open...
0
1431
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 .tmpl file... Can anyone get me a demo screen 4 d same showing a tree on the left and when we click any link in the tree, corresponding page(.tmpl) page opens up on right... This is a simple Tree Example>>>>>>> file name="mytreeapp.py" import...
0
8345
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8858
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8634
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5657
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4182
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4349
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2763
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1757
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.