SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member cje9250's Avatar
    Join Date
    May 2004
    Location
    St. Joseph
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy getElementById problem

    I need help trying to open up a switch menu when a page is loaded but seem to keep getting the same error.
    Here is what is closing all of the menus upon refresh of the page....
    if (document.getElementById){
    document.write('<style type="text/css">\n')
    document.write('.submenu{display: none;}\n')
    document.write('</style>\n')
    }

    Here is how Im getting my folder name.......
    function GetDept(hrefIn){
    var daURL = hrefIn;
    daURL = daURL.split("/");
    var folder = daURL[6];

    return folder;
    }

    Here is how Im switching between menus.....
    function SwitchMenu(obj){
    if(document.getElementById){
    var el = document.getElementById(obj);
    var ar = new Array();
    ar = document.getElementById("tablenav").getElementsByTagName("span");

    if (ar.length != 0){
    for (var i=0; i<4; i++){
    alert(i);
    if (ar[i].className=="submenu") ar[i].style.display = "none";
    }
    }
    switch(GetDept(location.href)){
    //These cs, ets, es, etc.... is folder names
    case "cs":el.style.display = "block";break;
    case "ets":el.style.display = "block";break;
    case "es":el.style.display = "block";break;
    case "wms":el.style.display = "block";break;
    case "rm":el.style.display = "block";break;
    case "index.shtml":el.style.display = "block";break;
    default:
    alert("Default Switch");
    el.style.display = "none";
    break;
    }
    //}else{
    // el.style.display = "none";
    //}
    //Didn't want the menu to close after opening
    }
    }

    and here is where I get lost on the code......
    function OpenMenu(deptIn){
    if (somethinggoeshere(otherdepts probably) != deptIn){

    //I need to have the menu open that was clicked on from the last page
    //(the name can be gotten in this page as deptIn)
    //I dont know what to do because the page is refreshed everytime

    }
    return true;
    }

  2. #2
    SitePoint Member cje9250's Avatar
    Join Date
    May 2004
    Location
    St. Joseph
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Does anyone know a solution to my problem?

    Solution please.

  3. #3
    SitePoint Member cje9250's Avatar
    Join Date
    May 2004
    Location
    St. Joseph
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking I got it

    I fixed the problem with hit & miss but thanks alot.


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
  •