SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard Pedro Monteiro's Avatar
    Join Date
    Sep 2002
    Location
    Lisbon
    Posts
    1,393
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Variable calling a Menu item ID problem.

    I am having a problem with a navigation system I'm trying to implement in a client's site.

    The basic concept of the system is when an item is chosen, it's correspondent link and image stays chosen in a static way.

    This is the code used to perform this action:

    <SCRIPT language=JavaScript>
    var IJactiveID2 = "75206B75-CDB9-4F40-A916C064F9BA10CB";
    IJWriteMenu2();
    setupMenu("2BF87265-879F-44D4-9ACEABCC91109B0A");
    </SCRIPT>

    This is the code that associates the links with the images:

    <SCRIPT language=Javascript><!--
    MenuLayerName="IJMenu";
    preloadImage("AAA5435D-E0DF-488A-B9D52CEE890E4539", "../images/1-EN.gif", "../images/1-EN-over.gif");
    preloadImage("C9990F0B-31A2-4FF1-811D779A9681690A", "../images/2-EN.gif", "../images/2-EN-over.gif");
    preloadImage("1B0A8804-C9D7-45DC-9326C87BE332BD5B", "../images3-EN.gif", "../images/3-EN-over.gif");
    preloadImage("7D21970E-459F-4A40-B78C6F7714AC906D", "../images4-EN.gif", "../images/4-EN-over.gif");
    preloadImage("8BE088A7-A905-4A9D-B96D446FC8A40673", "../images5-EN.gif", "../images/5-EN-over.gif");
    preloadImage("B6307C94-811E-48DC-B048F2DAD903A47B", "../images6-EN.gif", "../images/6-EN-over.gif");
    preloadImage("2BF87265-879F-44D4-9ACEABCC91109B0A", "../images7-EN.gif", "../images/7-EN-over.gif");
    //--></SCRIPT>

    These are the menu items and the correspondent submenu items

    <SCRIPT language=JavaScript>
    menu = [];
    menu[0] = {id: "SC064D35-674D-4A71-AC2BDAB09407F436", template: "index.php", display: "Objectivos & Estratégia"};
    menu[1] = {id: "BC060D35-674D-4A71-AC2BDAB09407F436", template: "index.php", display: "Market"};
    menu[2] = {id: "75206B75-CDB9-4F40-A916C064F9BA10CB", template: "index.php", display: "Board of Directors"};
    menu[3] = {id: "B43433EB-9951-493A-93934790C41D4AF7", template: "index.php", display: "Management"};
    menu[4] = {id: "ABD530FC-A22E-4664-810EAC831E03D8B7", template: "index.php", display: "Organisation"};
    menu[5] = {id: "70D3FA7E-41B0-49AF-B9BBD828B376926B", template: "index.php", display: "Corporate Governance"};
    menu[6] = {id: "1D21FDA0-1F6B-412A-8EC42A9F581F721B", template: "index.php", display: "History"};
    menu[7] = {id: "F410B877-6967-4708-8E61085CDD9497EC", template: "index.php", display: "Sponsoring"};
    IJmenuArray[0] = {id: "AAA5435D-E0DF-488A-B9D52CEE890E4539", items: menu};
    </SCRIPT>

    My problem is that I am using a template engine system in the site, thus when a user choses a link form the menu I need the first code I presented to chose the correct Menu Item ID. I cannot insert the code on each page as I'm only using one template for all the pages. This way, var IJactiveID2 needs to fetch an item ID depending what link is chosen. So I need the ID's to be variables rather then links.

    Any idea how to do this?

    I'm sure I did a pretty bad job explaining myself, but I'm hoping somone can help me out.

    My best regards
    Last edited by Pedro Monteiro; Dec 17, 2003 at 03:19.

  2. #2
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ... thus when a user choses a link form the menu...
    We need to see that event handler code. Is the page online?

    Also... are those the values of html ID attributes? An ID can not start with a digit.

  3. #3
    SitePoint Wizard Pedro Monteiro's Avatar
    Join Date
    Sep 2002
    Location
    Lisbon
    Posts
    1,393
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is this what you mean?

    P.S. Thank you for the help!

    ___________________________________________________________

    menuls.js

    function
    IJPopup(a)
    {
    window.open(a.href,'IJPopup','resizable=yes,scrollbars=yes,width=450,height=600');
    return false;
    }
    function
    toggleLayer(l)
    {
    if (document.layers) {
    if (l.visibility != "show") {
    l.visibility = "show";
    } else {
    l.visibility = "hide";
    }
    } else {
    if (l.style.visibility != "visible") {
    l.style.visibility = "visible";
    } else {
    l.style.visibility = "hidden";
    }
    }
    }


    var IJmenuArray = [];
    function
    IJWriteMenu2()
    {
    var m = 0;
    while (m < IJmenuArray.length) {
    me = IJmenuArray[m];
    document.write("<div id=\"menu-"+me.id+"\" class=\""+(m < 4 ? "IJMenu2" : "IJMenu2Right")+"\">");
    var menu = me.items;
    var i = 0;
    while (i < menu.length) {
    var mi = menu[i];
    document.write("<a href=\""+mi.template+"?ID="+mi.id+"\""+(mi.id == IJactiveID2 ? " class=\"IJActive\"" : "")+">"+mi.display+'</a>');
    i++;
    if (i < menu.length) {
    document.write(" | ");
    }
    }
    document.writeln("</div>");

    m++;
    }
    }

    ______________________________________________________________

  4. #4
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think I understand better now. When the user clicks one of the links a new page is loaded, and that new page needs to know the ID of the link that was clicked on the previous page. Is that right? If so, then here are two options:

    1) append the ID to the URL:
    mysite.com/mypage.html?id=SC064D35-674D-4A71-AC2BDAB09407F436

    2) store the ID as a cookie


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
  •