Help with Javascript menu needed!

This is a discussion on "Help with Javascript menu needed!" within the JavaScript Forum section. This forum, and the thread "Help with Javascript menu needed! are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jan 26th, 2008, 14:35
New Member
Join Date: Jan 2008
Location: galashiels
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Help with Javascript menu needed!

Hello everyone,

I'm a bit of a beginner here and trying to develop my website. My only stumbling block at the moment is installing a javascript menu.

So far I have inserted the following code using Slashdot menu script:

Code: Select all
<SCRIPT type=text/javascript>
  /***********************************************
  * Slashdot Menu script- By DimX
  * Submitted to Dynamic Drive DHTML code library: http://www.dynamicdrive.com
  * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
  ***********************************************/
  
/* Slashdot's Menu */
var remember = true;   //Remember menu states, and restore them on next visit. (Overrides contractall_default)
var contractall_default = true;   //Should all submenus be contracted by default? (true or false)
var filesdir = "/images/singletrackbikes";   //Directory where the images are located.
var bypixels = 3;   //Basicly it's speed.
/* No need to change below. */
var menu, titles, submenus, arrows, heights = new Array();
///// DD added expandall() and contractall() functions /////
function slash_expandall() {
    if (typeof menu != "undefined") {
     for(i = 0; i < Math.max(titles.length, submenus.length); i++){
      titles[i].className = "title";
      arrows[i].src = filesdir + "/expanded.gif";
      submenus[i].style.display = "";
      submenus[i].style.height = heights[i]+"px";
     }
    }
}
function slash_contractall(){
    if (typeof menu != "undefined") {
     for(i = 0; i < Math.max(titles.length, submenus.length); i++){
      titles[i].className = "titlehidden";
      arrows[i].src = filesdir + "/collapsed.gif";
      submenus[i].style.display = "none";
      submenus[i].style.height = 0;
     }
    }
}
///// End DD added functions ///////////////////////////////

function init(){
    menu = getElementsByClassName("sdmenu", "div", document)[0];
    titles = getElementsByClassName("title", "span", menu);
    submenus = getElementsByClassName("submenu", "div", menu);
    arrows = getElementsByClassName("arrow", "img", menu);
    for(i=0; i<Math.max(titles.length, submenus.length); i++) {
        titles[i].onclick = gomenu;
        arrows[i].onclick = gomenu;
        heights[i] = submenus[i].offsetHeight;
        submenus[i].style.height = submenus[i].offsetHeight+"px";
    }
    if(remember)
  restore();
 else if (contractall_default) //DD added code
  slash_contractall(); //DD added code
}
function restore() {
    if(getcookie("menu") != null) {
        var hidden = getcookie("menu").split(",");
        for(var i in hidden) {
            titles[hidden[i]].className = "titlehidden";
            submenus[hidden[i]].style.height = "0px";
            submenus[hidden[i]].style.display = "none";
            arrows[hidden[i]].src = filesdir + "/collapsed.gif";
        }
    } else if(contractall_default) {
        slash_contractall();
    }
}
function gomenu(e) {
    if (!e)
        var e = window.event;
    var ce = (e.target) ? e.target : e.srcElement;
    var sm;
    for(var i in titles) {
        if(titles[i] == ce || arrows[i] == ce)
            sm = i;
    }
    if(parseInt(submenus[sm].style.height) > parseInt(heights[sm])-2) {
        hidemenu(sm);
    } else if(parseInt(submenus[sm].style.height) < 2) {
        titles[sm].className = "title";
        showmenu(sm);
    }
}
function hidemenu(sm) {
    var nr = submenus[sm].getElementsByTagName("a").length*bypixels;
    submenus[sm].style.height = (parseInt(submenus[sm].style.height)-nr)+"px";
    var to = setTimeout("hidemenu("+sm+")", 30);
    if(parseInt(submenus[sm].style.height) <= nr) {
        clearTimeout(to);
        submenus[sm].style.display = "none";
        submenus[sm].style.height = "0px";
        arrows[sm].src = filesdir + "/collapsed.gif";
        titles[sm].className = "titlehidden";
    }
}
function showmenu(sm) {
    var nr = submenus[sm].getElementsByTagName("a").length*bypixels;
    submenus[sm].style.display = "";
    submenus[sm].style.height = (parseInt(submenus[sm].style.height)+nr)+"px";
    var to = setTimeout("showmenu("+sm+")", 30);
    if(parseInt(submenus[sm].style.height) > (parseInt(heights[sm])-nr)) {
        clearTimeout(to);
        submenus[sm].style.height = heights[sm]+"px";
        arrows[sm].src = filesdir + "/expanded.gif";
    }
        
        
}
function store() {
    var hidden = new Array();
    for(var i in titles) {
        if(titles[i].className == "titlehidden")
            hidden.push(i);
    }
    putcookie("menu", hidden.join(","), 30);
}
function getElementsByClassName(strClassName, strTagName, oElm){
    var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for(var i=0; i<arrElements.length; i++){
        oElement = arrElements[i];      
        if(oRegExp.test(oElement.className)){
            arrReturnElements.push(oElement);
        }   
    }
    return (arrReturnElements)
}
function putcookie(c_name,value,expiredays) {
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie = c_name + "=" + escape(value) + "; path=/" + ((expiredays==null) ? "" : "; expires="+exdate);
}
function getcookie(c_name) {
    if(document.cookie.length > 0) {
        var c_start = document.cookie.indexOf(c_name + "=");
        if(c_start != -1) {
            c_start = c_start + c_name.length + 1;
            var c_end = document.cookie.indexOf(";",c_start);
            if(c_end == -1)
                c_end = document.cookie.length;
            return unescape(document.cookie.substring(c_start, c_end));
        }
    }
    return null;
}
window.onload = init;
if(remember) window.onunload = store;
  
  
 </SCRIPT>
The web url is http://flowactive.web-epos.com/ and it a beta site. The system we use doesnt allow you to access the server directly but Ive asked the administrator to insert the jsmenu javascript file.

Is this the correct thing to do as I can't get the menu to appear? Could it be that the administrator hasnt put on the js file yet?

Any help much appretiated!

Last edited by Rakuli; Jan 26th, 2008 at 14:47. Reason: Please use [code] tags when posting scripts
Reply With Quote

  #2 (permalink)  
Old Jan 26th, 2008, 14:53
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Help with Javascript menu needed!

Have you put the HTML on your page that this javascript references? Did you give that to the server administrator as well?

Never mind that.. I just looked at the page and the administrator has put the code one the page but there are no HTML elements to build the menu from. There is nothing with required class names.

You will need to go back to dynamic drive and follow the instructions they give.

Inside the zip file on the site there is a HTML file that contains the HTML to be included on the page, it would appear the admin hasn't added that part.

Cheers
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Reply With Quote
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting the javascript menu to remember dangergeek JavaScript Forum 2 Sep 5th, 2007 00:22
JavaScript Menu - HELP Plz , URGENT prismmb JavaScript Forum 1 Oct 13th, 2006 17:49
Horizontal menu help needed AdRock Web Page Design 9 Oct 2nd, 2006 17:50
Javascript Menu mj187 JavaScript Forum 1 Dec 5th, 2005 17:28
CSS and Javascript Drop down menu barrysmith JavaScript Forum 2 Jul 20th, 2005 12:35


All times are GMT. The time now is 04:52.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43