SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2002
    Location
    Dublin, Ireland
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript Menu problem

    Hi!

    I have done a new navigation system for a mate using javascript. My problem:

    As you click on each dropdown menu option the subsequent links are visible however if you move on to another option the previous one remains extended. The visitor has to click it again to withdraw.

    How can I rectify this so that if a visitor clicks a different dropdown option the previous one is retracted? You can see it at http://www.irish-forestry.ie/profilepage.htm(the left frame). I have included the code below should you need to see the archaic way I have approched this but bear in mind I am only learning!!

    Cheers,
    Jamie


    (see below)

    <style>
    <!--
    body {margin-top:0px;
    margin-left:0px;}
    {font-size:9px;font-family:verdana;}
    a {font-weight: bold;
    text-decoration: none;
    color: #FFFFFF;}
    a:hover {font-weight: none;
    text-decoration:none;}
    ul {margin-left:20px;}
    #foldheader {cursor:hand; font-weight:bold; color:#009900; list-style-image:url(images/fold.gif)}
    #foldinglist {font-weight:bold; color:#ffffff; list-style-image:url(images/list.gif)}
    //-->



    </style>
    <script language="JavaScript1.2">
    <!--

    var head="display:''"
    img1=new Image()
    img1.src="fold.gif"
    img2=new Image()
    img2.src="open.gif"

    function change(){
    if(!document.all)
    return
    if (event.srcElement.id=="foldheader") {
    var srcIndex = event.srcElement.sourceIndex
    var nested = document.all[srcIndex+1]
    if (nested.style.display=="none") {
    nested.style.display=''
    event.srcElement.style.listStyleImage="url(images/open.gif)"
    }
    else {
    nested.style.display="none"
    event.srcElement.style.listStyleImage="url(images/fold.gif)"
    }
    }
    }

    document.onclick=change

    //-->
    </script>

    </HEAD>

    <BODY bgcolor="#141527">

    <body><br><br>
    <ul align="left">
    <li id="foldheader">Forestry Investment Plan</li>
    <ul id="foldinglist" style="display:none" style=&{head};>
    <li id="foldheader">FIP 1</li>
    <ul id="foldinglist" style="display:none" style=&{head};>
    <li><a href="fip1.htm" target="content">Home</a></li>
    <li><a href="onlinedocs.htm#FIP1" target="content">Documents</a></li>
    <li><a href="mgt.htm" target="content">Management Team</a></li>
    </ul>
    <li id="foldheader">FIP 2</li>
    <ul id="foldinglist" style="display:none" style=&{head};>
    <li><a href="fip2.htm" target="content">Home</a></li>
    <li><a href="onlinedocs.htm#FIP2" target="content">Documents</a></li>
    <li><a href="mgt.htm" target="content">Management Team</a></li>
    </ul>
    <li id="foldheader">FIP 3</li>
    <ul id="foldinglist" style="display:none" style=&{head};>
    <li><a href="fip3.htm" target="content">Home</a></li>
    <li><a href="onlinedocs.htm#FIP3" target="content">Documents</a></li>
    <li><a href="mgt.htm" target="content">Management Team</a></li>
    </ul>
    <li id="foldheader">FIP 4</li>
    <ul id="foldinglist" style="display:none" style=&{head};>
    <li><a href="fip4.htm" target="content">Home</a></li>
    <li><a href="onlinedocs.htm#4IFFmain" target="content">Documents</a></li>
    <li><a href="mgt.htm" target="content">Management Team</a></li>
    </ul>

    </ul>

    <li id="foldheader">Irish Forestry Funds</li>
    <ul id="foldinglist" style="display:none" style=&{head};>
    <li id="foldheader">2nd IFF</li>
    <ul id="foldinglist" style="display:none" style=&{head};>
    <li><a href="2iff.htm" target="content">Home</a></li>
    <li><a href="onlinedocs.htm#2IFF" target="content">Documents</a></li>
    <li><a href="2iffland.htm" target="content">Land Purchased</a></li>
    <li><a href="mgt.htm" target="content">Management Team</a></li>
    </ul>
    <li id="foldheader">3rd IFF</li>
    <ul id="foldinglist" style="display:none" style=&{head};>
    <li><a href="3iff.htm" target="content">Home</a></li>
    <li><a href="onlinedocs.htm#3IFF" target="content">Documents</a></li>
    <li><a href="3iffland.htm" target="content">Land Purchased</a></li>
    <li><a href="mgt.htm" target="content">Management Team</a></li>
    </ul>
    <li id="foldheader">4th IFF</li>
    <ul id="foldinglist" style="display:none" style=&{head};>
    <li><a href="4iff.htm" target="content">Home</a></li>
    <li><a href="onlinedocs.htm#4IFF" target="content">Documents</a></li>
    <li><a href="4iffland.htm" target="content">Land Purchased</a></li>
    <li><a href="mgt.htm" target="content">Management Team</a></li>
    </ul>
    <li id="foldheader">5th IFF</li>
    <ul id="foldinglist" style="display:none" style=&{head};>
    <li><a href="5iff.htm" target="content">Home</a></li>
    <li><a href="onlinedocs.htm#5IFF" target="content">Documents</a></li>
    <li><a href="5iffland.htm" target="content">Land Purchased</a></li>
    <li><a href="mgt.htm" target="content">Management Team</a></li>
    </ul>
    <li id="foldheader">6th IFF</li>
    <ul id="foldinglist" style="display:none" style=&{head};>
    <li><a href="6iff.htm" target="content">Home</a></li>
    <li><a href="onlinedocs.htm#6IFF" target="content">Documents</a></li>
    <li><a href="6iffland.htm" target="content">Land Purchased</a></li>
    <li><a href="mgt.htm" target="content">Management Team</a></li>
    </ul>
    <li id="foldheader">7th IFF</li>
    <ul id="foldinglist" style="display:none" style=&{head};>
    <li><a href="7iff.htm" target="content">Home</a></li>
    <li><a href="onlinedocs.htm#7IFF" target="content">Documents</a></li>
    <li><a href="7iffland.htm" target="content">Land Purchased</a></li>
    <li><a href="mgt.htm" target="content">Management Team</a></li>
    </ul>
    </ul>
    <li id="foldheader">Further Information</li>
    <ul id="foldinglist" style="display:none" style=&{head};>
    <li><a href="onlinedocs.htm" target="content">Online Documents</a></li>
    <li><a href="faq.htm" target="content">FAQs</a></li>
    <li><a href="indprof.htm" target="content">Industry Information</a></li>
    <li><a href="links.htm" target="content">Links</a></li>
    </ul>
    <li id="foldheader">Request Information</li>
    <ul id="foldinglist" style="display:none" style=&{head};>
    <li><a href="inforeq.htm" target="content">Online Request</a></li>
    <li><a href="contact.htm" target="content">Contact Details</a></li>
    <li><a href="shares.htm" target="content">Trading the Shares</a></li>
    </ul>
    <!--photo gallery
    <li id="foldheader">Photo Gallery</li>
    <ul id="foldinglist" style="display:none" style=&{head};>
    <li><a href="photopage1.htm" target="content">Gallery 1</a></li>
    <li><a href="photopage2.htm" target="content">Gallery 2</a></li>
    </ul>
    -->


    </ul>
    <script language="JavaScript1.2">
    <!--

    function get_cookie(Name) {
    var search = Name + "="
    var returnvalue = "";
    if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    // if cookie exists
    if (offset != -1) {
    offset += search.length
    // set index of beginning of value
    end = document.cookie.indexOf(";", offset);
    // set index of end of cookie value
    if (end == -1) end = document.cookie.length;
    returnvalue=unescape(document.cookie.substring(offset, end))
    }
    }
    return returnvalue;
    }

    if (get_cookie(window.location.pathname) != ''){
    var openresults=get_cookie(window.location.pathname).split(" ")
    for (i=0 ; i < openresults.length ; i++){
    foldinglist[openresults[i]].style.display=''
    document.all[foldinglist[openresults[i]].sourceIndex -
    1].style.listStyleImage="url(images/open.gif)"
    }
    }

    if (document.all){
    var nodelength=foldinglist.length-1
    var nodes=new Array(nodelength)
    var openones=''
    }

    function check(){
    for (i=0 ; i <= nodelength ; i++){
    if (foldinglist[i].style.display=='')
    openones=openones + " " + i
    }
    document.cookie=window.location.pathname+"="+openones
    }

    if (document.all)
    document.body.onunload=check
    //-->
    </script>http://www.irish-forestry.ie/fip4frame.htm http://www.irish-forestry.ie/fip4frame.htm www.irish-forestry.ie/fip4frame.htm

  2. #2
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I created a similar script using the display choice instead of visibility saved many 100's of lines of code. Anyways this is how to do it in pseudo code. I don'thave time to go through your code and find the correct way right now but

    capture the onlick (which you have done)
    call a function (which you have done)
    figure out a way to loop through all submenus (I use a name with a corresponding number like bob1, bob2)
    cycle through each of those submenus
    turn the disply off
    turn the display of the one clikc (by passing the name through the function) to '' (or show it)


    that does work quie well. Best of luck
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2002
    Location
    Dublin, Ireland
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a million Maelstrom!!

  4. #4
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My pleasure, did it work out for you?
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  5. #5
    SitePoint Enthusiast
    Join Date
    Feb 2002
    Location
    Dublin, Ireland
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking

    Hi Maelstrom!

    I am going to give it a go over the weekend. At the moment i am doing some work experience so my mate will have to wait just a little longer.

    Cheers,
    Jamie


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
  •