Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-16-2004, 12:25 AM   PM User | #1
maddogzD
New to the CF scene

 
Join Date: Aug 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
maddogzD is an unknown quantity at this point
dynamic folder tree menu not folding

Hello all.....

I got a Switch Menu script from Dynamic Drive - a folding tree nav menu. Didn't have to do much configuring of the html - just changed a span to a div, but I think that's messing up in the javascript.

This is the html for a menu entry and a sub menu:
<.div id="masterdiv">

<div class="menutitle" onclick="SwitchMenu('sub1')"><a href="index.php?page=ministries/adults">Adults</a></div>
<div class="submenu" id="sub1">
<a href="index.php?page=ministries/adults">Adult Fellowships</a><br>
<a href="index.php?page=ministries/adults">Adult Electives</a><br>
<a href="index.php?page=ministries/adults">Home Bible studies</a><br>
<a href="index.php?page=ministries/adults">What about Sunday School?</a>
<./div>
<./div>

I changed the submenu span class to a div class because the span class was only indenting the first line of the submenu.

This is the javascript:
<script type="javascript">
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").getElementsByTagName("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";
}
}
}

</script>

The problem is that the page opens with the menu opened up and it's not collapsing when the top level link is clicked. Here it is in action:
http://mckinneychurch.com/checkthiso...age=ministries
It's the list in the right side column - the submenus are indented 15px.

What might the matter be? Thanks for any attention!

sherill
maddogzD is offline   Reply With Quote
Old 08-16-2004, 12:42 AM   PM User | #2
maddogzD
New to the CF scene

 
Join Date: Aug 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
maddogzD is an unknown quantity at this point
wrong forum?

I suppose I should have put this in the Dynamic Drive scripts help forum. How do I go about moving it? So sorry!!

sherill
maddogzD is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:12 PM.


Advertisement
Log in to turn off these ads.