Results 1 to 4 of 4

Thread: Switch menu: switchable section inside switchable section?

  1. #1
    Join Date
    Nov 2005
    Location
    Sydney, Australia
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Switch menu: switchable section inside switchable section?

    Switch menu
    http://www.dynamicdrive.com/dynamici...switchmenu.htm

    I really like the Switch menu and it has been perfect for my needs.
    But I was just wondering if there was a way to put another switchable section inside a switchable section; thus it would only be seen when the section which contained it was 'switched'.
    This isn't a question of having more than one menu one a site, merely just adding another part to the one I already have.

    Here is what I think is the important bit of the code. The rest can be found on the above page.

    Javascript:
    Code:
    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";
    		}
    	}
    }
    HTML menu code (unaltered):
    Code:
    <div id="masterdiv">
    
    <div class="menutitle" onclick="SwitchMenu('sub1')">Site Menu</div>
    <span class="submenu" id="sub1">
    	- <a href="new.htm">What's New</a><br>
    	- <a href="hot.htm">What's hot</a><br>
    	- <a href="revised.htm">Revised Scripts</a><br>
    	- <a href="morezone/">More Zone</a>
    </span>
    
    <div class="menutitle" onclick="SwitchMenu('sub2')">FAQ/Help</div>
    <span class="submenu" id="sub2">
    	- <a href="notice.htm">Usage Terms</a><br>
    	- <a href="faqs.htm">DHTML FAQs</a><br>
    	- <a href="help.htm">Scripts FAQs</a>
    </span>
    
    <div class="menutitle" onclick="SwitchMenu('sub3')">Help Forum</div>
    <span class="submenu" id="sub3">
    	- <a href="http://www.codingforums.com">Coding Forums</a><br>
    </span>
    	
    <div class="menutitle" onclick="SwitchMenu('sub4')">Cool Links</div>
    <span class="submenu" id="sub4">
    	- <a href="http://www.javascriptkit.com">JavaScript Kit</a><br>
    	- <a href="http://www.freewarejava.com">Freewarejava</a><br>
    	- <a href="http://www.cooltext.com">Cool Text</a><br>
    	- <a href="http://www.google.com">Google.com</a>
    </span>
    
    <img src="about.gif" onclick="SwitchMenu('sub5')"><br>
    <span class="submenu" id="sub5">
    	- <a href="http://www.dynamicdrive.com/link.htm">Link to DD</a><br>
    	- <a href="http://www.dynamicdrive.com/recommendit/">Recommend</a><br>
    	- <a href="http://www.dynamicdrive.com/contact.htm">Email</a><br>
    </span>
    
    </div>

    And this doesn't work:

    Code:
    	<div class="menutitle" onclick="SwitchMenu('sub2')">FAQ/Help</div>
    <span class="submenu" id="sub2">
    	- <a href="notice.htm">Usage Terms</a><br>
    		<div class="menutitle" onclick="SwitchMenu('sub6')">FAQ/Help</div>
    		<span class="submenu" id="sub6">
    		- <a href="faqs.htm">DHTML FAQs</a><br>
    		</span>
    	- <a href="help.htm">Scripts FAQs</a>
    </span>
    I hope somebody can help.
    Thanks in advance!
    Last edited by GranoSalis; 11-26-2005 at 01:12 AM. Reason: cleaning up code

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,926
    Thanks
    43
    Thanked 3,192 Times in 3,155 Posts
    Blog Entries
    12

    Default

    See this thread and particularly post_#6 from it. Let us know if you still have questions.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Nov 2005
    Location
    Sydney, Australia
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Sorry, I looked to see if a similar question had previously been asked but couldn't find one.
    Thanks!

  4. #4
    Join Date
    Nov 2005
    Location
    Sydney, Australia
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks, just had a look at that thread, your code works like a charm!
    My problem is solved! Thanks again!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •