Results 1 to 4 of 4

Thread: Issue with DD sideMenuBar

  1. #1
    Join Date
    Feb 2013
    Location
    California
    Posts
    53
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Default Issue with DD sideMenuBar

    I have long been a user of the DD sideMenuBar for several of my sites. Recently I noticed that it throws an error at the following line:

    Code:
    var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
    Not knowing that much about javascript it appears that the problem is that I sometimes have only one or two levels declared but the script is looking for three levels.

    Is there a work-around for this? It is not a showstopper but is really annoying when testing.

    jdadwilson

  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

    Please post about Dynamic Drive Scripts in the Dynamic Drive Scripts Help section here where I've moved this thread, and:

    Warning: Please include a link to the DD script(s) in question in your post. See this post for more information.


    This sort of problem is usually due to declaring more menus and/or sub menus than you realize.

    If you want more help, please include a link to the page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

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

  3. #3
    Join Date
    Feb 2013
    Location
    California
    Posts
    53
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Default

    Here is a link to a page that gets the error...

    [URL="http://www.txfannin.org/census.php[/URL]

    Using sideBarMenu in this instance I would assume that I would only need one declaration in the script.

    [QUOTE]var menuids=["sidebarmenu1"][/QUOTE]

    But since I use the script across multiple pages where I might have two or three sub menus, don't I need to declare all of them?

    Thanks for your assistance...
    jdadwilson

  4. #4
    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

    Change:

    Code:
    var menuids=["sidebarmenu1", "sidebarmenu2", "sidebarmenu3"] //Enter id(s) of each Side Bar Menu's main UL, separated by commas
    to:

    Code:
    var menuids=["sidebarmenu1"] //Enter id(s) of each Side Bar Menu's main UL, separated by commas
    That will fix that one menu.

    The browser cache may need to be cleared and/or the page refreshed to see changes.

    If you have different menus with more or less menuids on different pages all using the same external script, instead of declaring this variable in the external script, declare it on each page before the external tag to the Side Menu Bar script. that would mean, removing:

    Code:
    var menuids=["sidebarmenu1", "sidebarmenu2", "sidebarmenu3"] //Enter id(s) of each Side Bar Menu's main UL, separated by commas
    from the script and, for example on the page you linked to (census.php) add the highlighted:

    Code:
    <script type="text/javascript" src="//code.jquery.com/jquery-1.10.2.min.js"></script>
    <script type="text/javascript" src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
    <script type="text/javascript" src="files_java/jquery.dataTables.1.09.4.min.js"></script>
    <script type="text/javascript" src="files_java/jquery.dataTables.tableTools.2.2.1-dev.js"></script>
    <script type="text/javascript" src="files_java_mine/site_functions.js"></script>
    <script type="text/javascript" src="files_java/jquery.functions.js"></script>
    <script type="text/javascript">
    var menuids=["sidebarmenu1"] //Enter id(s) of each Side Bar Menu's main UL, separated by commas
    </script>
    <script type="text/javascript" src="files_java/sideBarMenu.js"></script>
    <script type="text/javascript" src="files_java/equalcolumns.js"></script>
    
    <script type="text/javascript" src="files_java/tableRowHilite.js"></script>
    OR you could use this modified version of the script:

    Code:
    //	Nested Side Bar Menu (Mar 20th, 09)
    //	By Dynamic Drive: http://www.dynamicdrive.com/style/
    
    var menuids=["sidebarmenu1", "sidebarmenu2", "sidebarmenu3"] //Enter id(s) of each Side Bar Menu's main UL, separated by commas
    
    function initsidebarmenu()
    {
    	for (var i=0; i<menuids.length; i++)
    	{
    		if(document.getElementById(menuids[i]))
    		{
    			var ultags = document.getElementById(menuids[i]).getElementsByTagName("ul")
    			for (var t=0; t<ultags.length; t++)
    			{
    				ultags[t].parentNode.getElementsByTagName("a")[0].className+=" subfolderstyle"
    				if (ultags[t].parentNode.parentNode.id==menuids[i]) //if this is a first level submenu
    					//dynamically position first level submenus to be width of main menu item
    					ultags[t].style.left=ultags[t].parentNode.offsetWidth+"px" 
    				else //else if this is a sub level submenu (ul)
    					//position menu to the right of menu item that activated it
    					ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px" 
    				ultags[t].parentNode.onmouseover=function()
    				{
    					this.getElementsByTagName("ul")[0].style.display="block"
    				}
    				ultags[t].parentNode.onmouseout=function()
    				{
    					this.getElementsByTagName("ul")[0].style.display="none"
    				}
    			}
    			 //loop through all sub menus again, and use "display:none" to hide menus (to prevent possible page scrollbars
    			for (var t=ultags.length-1; t>-1; t--)
    			{
    				ultags[t].style.visibility="visible"
    				ultags[t].style.display="none"
    			}
    		}
    	}
    }
    
    if (window.addEventListener)
    	window.addEventListener("load", initsidebarmenu, false)
    else if (window.attachEvent)
    	window.attachEvent("onload", initsidebarmenu)
    Last edited by jscheuer1; 05-29-2014 at 02:23 PM. Reason: add updated script
    - John
    ________________________

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

Similar Threads

  1. Replies: 3
    Last Post: 02-15-2011, 01:37 AM
  2. AnyLink Drop Down Menu - border issue *and* FF alignment issue
    By trjonas in forum Dynamic Drive scripts help
    Replies: 3
    Last Post: 12-18-2007, 04:58 AM
  3. Email issue -- Carbon Copy Issue
    By Humper in forum HTML
    Replies: 0
    Last Post: 09-01-2006, 09:01 PM
  4. Email issue -- Carbon Copy Issue
    By Humper in forum PHP
    Replies: 1
    Last Post: 09-01-2006, 08:47 PM
  5. Email issue -- Carbon Copy Issue
    By Humper in forum JavaScript
    Replies: 0
    Last Post: 09-01-2006, 07:26 PM

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
  •