Results 1 to 2 of 2

Thread: Script: DD Switch Menu Additions help

  1. #1
    Join Date
    Dec 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Script: DD Switch Menu Additions help

    I found the above code to add more submenus http://www.dynamicdrive.com/forums/s...69&postcount=6,

    However, I am unable to get it to work in my VS 2005. When I click on a switch menu, the links below it show as 1st level links instead of 2nd level links. Can anyone help? Here is my coding:

    Code:
    /* PageMaster2 Switchmenu peorperties */
    
    .menutitle
    {
    cursorointer;
    margin-bottom: 5px;
    background-color: White;
    color: black;
    text-decoration:none;
    width:140px;
    padding:2px;
    text-align:center;
    font-weight:bold;
    border:1px solid Black;/* */
    }
    
    .submenu a:link 
    {
    text-indent: 10px;
    color: Lime;
    margin-bottom: 0.5em;
    }
    
    .submenu a:visited 
    {
    color:Lime;
    text-decoration:none;
    }
    
    .submenu a:hover
    {
    color: Red;
    text-decoration:none; 
    background-position: 100% -32px;
    }
    
    .submenu a:selected
    {
    color: Red;
    text-decoration:none;
    }
    
    /* ContentMaster Switchmenu peorperties */
    
    
    .menucontent
    {
    background-color: #033668;
    text-decoration:none;
    color: White; 
    font-family:Verdana, Arial, Helvetica, sans-serif;
    font-size:16px; 
    cursorointer;
    margin-bottom: 0px;
    width:0px;
    padding:0px;
    text-align:left;
    font-weight:bold;
    /*/*/border:1px solid #000000;/* */
    }
    
    .submenucontent a:link
    {
    color: yellow;
    text-indent: 10px;
    font-family:Verdana, Arial, Helvetica, sans-serif;
    font-size:12px; 
    text-decoration:none; 
    margin-bottom: 0.5em;
    }
    
    .submenucontent a:visited
    {
    color: Lime;
    text-decoration:none;
    }
    
    .submenucontent a:hover
    {
    color: Red;
    text-decoration:none; 
    background-position: 100% -32px;
    }
    
    .submenucontent a:selected
    {
    color: Aqua;
    text-decoration:none;
    }
    
    .ssubmenucontent a:link
    {
    color: yellow;
    text-indent: 10px;
    font-family:Verdana, Arial, Helvetica, sans-serif;
    font-size:12px; 
    text-decoration:none; 
    margin-bottom: 0.5em;
    }
    
    .ssubmenucontent a:visited
    {
    color: Lime;
    text-decoration:none;
    }
    
    .ssubmenucontent a:hover
    {
    color: Red;
    text-decoration:none; 
    background-position: 100% -32px;
    }
    
    .ssubmenucontent a:selected
    {
    color: Aqua;
    text-decoration:none;
    }
    
    .ssubmenu
    {
    margin-bottom: 0.5em;
    }
    Code:
    /***********************************************
    * Switch Menu script- by Martial B of http://getElementById.com/
    * Modified by Dynamic Drive for format & NS4/IE4 compatibility
    * Visit http://www.dynamicdrive.com/ for full source code
    ***********************************************/
    
    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('.submenucontent{display: none;}\n')
    document.write('.ssubmenucontent{display: none;}\n')
    document.write('</style>\n')
    }
    
    function SwitchMenu(obj){
    if(document.getElementById){
    var el = document.getElementById(obj);
    var ar = document.getElementById("masterdivcontent").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=="submenucontent") //DynamicDrive.com change
    ar[i].style.display = "none";
    }
    el.style.display = "block";
    }else{
    el.style.display = "none";
    }
    }
    }
    
    function SwitchsubMenu(obj){
    if(document.getElementById){
    var sel = document.getElementById(obj);
    var sar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
    if(sel.style.display != "block"){ //DynamicDrive.com change
    for (var i=0; i<sar.length; i++){
    if (sar[i].className=="ssubmenu") //DynamicDrive.com change
    sar[i].style.display = "none";
    }
    sel.style.display = "block";
    }else{
    sel.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"
    }
    if (persistmenu=="yes"){
    var scookiename=(persisttype=="sitewide")? "sswitchmenu" : "s"+window.location.pathname
    var scookievalue=get_cookie(scookiename)
    if (scookievalue!="")
    document.getElementById(scookievalue).style.display="block"
    }
    }
    
    function savemenustate(){
    var inc=1, blockid=""
    var sinc=1, sblockid=""
    while (document.getElementById("sub"+inc)){
    if (document.getElementById("sub"+inc).style.display=="block"){
    blockid="sub"+inc
    break
    }
    inc++
    }
    while (document.getElementById("ssub"+sinc)){
    if (document.getElementById("ssub"+sinc).style.display=="block"){
    sblockid="ssub"+sinc
    break
    }
    sinc++
    }
    var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
    var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid
    document.cookie=cookiename+"="+cookievalue
    var scookiename=(persisttype=="sitewide")? "sswitchmenu" : "s"+window.location.pathname
    var scookievalue=(persisttype=="sitewide")? sblockid+";path=/" : sblockid
    document.cookie=scookiename+"="+scookievalue
    }

    Code:
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head id="Head1" runat="server">
    <link href="PageMaster2.css" rel="stylesheet" type="text/css" />
    <link href="Print.css" rel="stylesheet" type="text/css" media="print" />
    <script language="javascript" type="text/javascript" src="../ContentScript.js"></script>
    <script language="javascript" type="text/javascript" src="../PrintScript.js"></script>
    <title>Page Master 2 Content Page</title>
    </head>
    
    <div id="masterdivcontent" onload="center" style="width:auto ">
    
    
    <div class="menucontent" style="width:100%; "><a href="../Pages/Default.aspx" title="HOME">HOME</a></div>
    <%--<span class="submenu" id="sub1" >
    <asp:HyperLink ID="HyperLink25" runat="server" ForeColor="Lime" Font-Size="Medium" navigateurl="~/Pages/Default.aspx" text="Home" tooltip="Home"></asp:HyperLink> 
    </span>--%>
    
    
    <div class="menucontent" style="width:100%;" onclick="SwitchMenu('sub1')">ASBESTOS / LEAD</div>
    <span class="submenucontent" id="sub1">
    <a href="/Pages/Asbestos.aspx" >Asbestos</a><br>
    <a href="" >Cert/Trng</a><br>
    <a href="" >Company</a><br>
    <a href="" >School &amp; Accred.</a><br>
    <a href="/Pages/Lead.aspx" >Lead</a><br />
    <div class="ssubmenucontent" onclick="SwitchsubMenu('ssub1')">Lead Forms</div>
    <span class=ssubmenu id=ssub1>
    <a href="../Pages/FormLIBI622L.aspx">Registration for Lead Certification Exam</a><br />
    </span>
    <a href="../Pages/InspectorActivity.aspx" >Inspector Activity</a><br>
    <a href="" >Violations</a>
    </span>
    
    <div class="menucontent" style="width:100%" onclick="SwitchMenu('sub2')">BEDDING &amp; UPHOLSTERY</div>
    <span class="submenucontent" id="sub2">
    <a href="" >New B &amp; U</a><br>
    <a href="" >Permits</a><br>
    <a href="" >Company</a><br>
    <a href="" >Secondhand</a><br>
    <a href="../Pages/InspectorActivity.aspx" >Inspector Activity</a><br>
    <a href="" >Toys</a>
    </span>
    </div>
    **I have edited out portions that do not apply to what I am doing.
    Last edited by jscheuer1; 12-28-2009 at 04:58 PM. Reason: format code

  2. #2
    Join Date
    Dec 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

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
  •