Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    still in need of Java for expanding menu transference -help?

    Hi,

    I am still trying to figure out if it's possible to take this menu and customize it so that when a page on the menu is clicked it carries the expand to the next page. This will help users know where they are at. (not breadcrumbs) I have included the head tag script and the body script. example..

    Lets say that this is the menu and I just clicked on Products...

    it expands, then I click on Incense and now I'm at the Incense page..

    the menu as it now stands closes back to the original state non expanded.

    Can someone help???


    Products
    Incense
    Perfume
    Candles
    Henna

    The <head tag>

    <script type="text/javascript">

    var persistmenu="yes" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
    var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only

    if (document.getElementById){ //DynamicDrive.com change
    document.write('<style type="text/css">\n')
    document.write('.submenu{display: none;}\n')
    document.write('</style>\n')
    }

    function SwitchMenu(obj){
    if(document.getElementById){
    var el = document.getElementById(obj);
    var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
    if(el.style.display != "block"){ //DynamicDrive.com change
    for (var i=0; i<ar.length; i++){
    if (ar[i].className=="submenu") //DynamicDrive.com change
    ar[i].style.display = "none";
    }
    el.style.display = "block";
    }else{
    el.style.display = "none";
    }
    }
    }

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

    function onloadfunction(){
    if (persistmenu=="yes"){
    var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
    var cookievalue=get_cookie(cookiename)
    if (cookievalue!="")
    document.getElementById(cookievalue).style.display="block"
    }
    }

    function savemenustate(){
    var inc=1, blockid=""
    while (document.getElementById("sub"+inc)){
    if (document.getElementById("sub"+inc).style.display=="block"){
    blockid="sub"+inc
    break
    }
    inc++
    }
    var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
    var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid
    document.cookie=cookiename+"="+cookievalue
    }

    if (window.addEventListener)
    window.addEventListener("load", onloadfunction, false)
    else if (window.attachEvent)
    window.attachEvent("onload", onloadfunction)
    else if (document.getElementById)
    window.onload=onloadfunction

    if (persistmenu=="yes" && document.getElementById)
    window.onunload=savemenustate

    </script>


    the <body>

    <!-- Keep all menus within masterdiv-->

    <div id="masterdiv">
    <div class="menutitle" onclick="SwitchMenu('sub1')"><a href="/orderform.htm"><font color="#FFFFFF">Order
    Form</font></a></div>
    <div class="menutitle" onclick="SwitchMenu('sub2')">Our
    Product Lines</div>
    <span class="submenu" id="sub2"> - <a href="/egyptiangoddess.htm">Egyptian
    Goddess</a><br>
    - <a href="/perfumeoils.htm">Perfume Oils</a><br>
    - <a href="/incense.htm">Incense</a><br>
    - <a href="/perfumesolids.htm">Perfume Solids</a><br>
    - <a href="/packagedincense.htm">Packaged Incense</a><br>
    - <a href="/temporarytattoos.htm">Temporary Tattoos</a><br>
    - <a href="/accessories.htm">Accessories</a><br>
    - <a href="/topsellerslist.htm">Top Sellers List</a> </span>
    <div class="menutitle" onclick="SwitchMenu('sub3')">About
    Auric Blends</div>
    <span class="submenu" id="sub3"> <a href="/auricblendshistory.htm">-
    History</a><br>
    - <a href="/businesspractices.htm">Our Business Practices</a><br>
    </span>
    <div class="menutitle" onclick="SwitchMenu('sub5')"><a href="/prayforpeace.htm"><font color="#FFFFFF">Pray
    for Peace</font></a></div>
    <div class="menutitle" onclick="SwitchMenu('sub6')"><a href="/sellingtips.htm"><font color="#FFFFFF">Selling
    Tips</font> </a></div>
    <div class="menutitle" onclick="SwitchMenu('sub7')">About
    Fragrance Products</div>
    <span class="submenu" id="sub7"> - <a href="/fragrancehistory.htm">Fragrance History</a><br>
    - <a href="/fragranceterminology.htm">Terminology</a></span>
    <div class="menutitle" onclick="SwitchMenu('sub8')">Fragrance
    Info</div>
    <span class="submenu" id="sub8"> -<a href="/fragranceindustryresources.htm">
    Industry Resources</a><br>
    - <a href="/fragranceindustrynews.htm">Fragrance News</a><br>
    </span>
    <div class="menutitle" onclick="SwitchMenu('sub9')"><a href="/newsletter.htm"><font color="#FFFFFF">Wholesale Newsletter</font></a></div>
    </div>
    <div class="menutitle" onclick="SwitchMenu('sub10')"><a href="/monthlyarticle.htm"><font color="#FFFFFF">Monthly
    Article</font></a></div>

    Can anyone help?

  • #2
    New Coder mentalhorse's Avatar
    Join Date
    Jul 2005
    Location
    Duanesburg, NY
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Frames.
    Why is a raven like a writing desk?

  • #3
    gph
    gph is offline
    Regular Coder
    Join Date
    Apr 2005
    Posts
    161
    Thanks
    0
    Thanked 0 Times in 0 Posts
    incrementing ID starting at 1 (id="sub1", id="sub2", etc)
    there is no sub1 so it stops looking. Try rereading the instructions.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •