Irish SEO,  Marketing & Webmaster Discussion

 

Javascript/CSS menu help?

This is a discussion on Javascript/CSS menu help? within the Coding Help forums, part of the Webmaster Help category; I've downloaded the code for a javascript/css menu and placed it into a new site I'm developing. However, I need ...


Go Back   Irish SEO, Marketing & Webmaster Discussion > Webmaster Help > Coding Help

Register Forum Rules FAQDonate Members List Calendar Search Today's Posts Mark Forums Read


Notices

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 15-04-2006, 12:40 PM
ButtermilkJack's Avatar
Wannabe Geek
 
Join Date: Feb 2006
Location: Dublin, Ireland
Posts: 265
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
ButtermilkJack will become famous soon enough
Default Javascript/CSS menu help?

I've downloaded the code for a javascript/css menu and placed it into a new site I'm developing. However, I need it to function differently to how it does 'out of the box'.

At the moment when you click on any link, the submenu appears below it. And when you click it again, it disappears. However, if you don't 'close' the submenu it will remain open when you click on another link. So the menu will grow very large if the user doesn't close submenus before going to another.

Does anyone know if the code can be modified to make all other submenus close if a new one is clicked open.

The code is below...

javascript:
Code:
menu_status = new Array();
function showHide(theid){
    if (document.getElementById) {
    var switch_id = document.getElementById(theid);

        if(menu_status[theid] != 'show') {
           switch_id.className = 'show';
           menu_status[theid] = 'show';
        }else{
           switch_id.className = 'hide';
           menu_status[theid] = 'hide';
        }
    }
}
CSS:
Code:
.menu1 {
    display: block;
    font-family: Helvetica, Arial, sans-serif;
    font-size: 1.2em;
    font-variant: small-caps;
    color: #000000;
    }
a.menu1 {
    background-color: #fe9d20;
    height: 18px;
    margin: 0;
    padding: 2px 10px;
    text-decoration: none;
    border-bottom: 1px solid #ffffff;
    cursor: pointer;
    cursor: hand;
    }
a:hover.menu1 {
    background-color: #dddddd;
    }
.submenu {
    display: block;
    font-family: Helvetica, Arial, sans-serif;
    font-size: 1.2em;
    font-variant: small-caps;
    color: #000000;
    }
a.submenu {
    background-color: #ffb874;
    height: 18px;
    margin: 0;
    padding: 2px 15px;
    text-decoration: none;
    border-bottom: 1px solid #ffffff;
    cursor: pointer;
    cursor: hand;
    }
a:hover.submenu {
    background-color: #dddddd;
    }
.hide {
    display: none;
    }
.show {
    display: block;
    }
HTML:
Code:
<a class="menu1" onclick="showHide('menu1')">home</a>
            <div id="menu1" class="hide">
                <a href="#" class="submenu">link one here</a>
            </div>
        <a class="menu1" onclick="showHide('menu2')">expertise</a>
            <div id="menu2" class="hide">
                <a href="#" class="submenu">staff one</a>
                <a href="#" class="submenu">staff two</a>
                <a href="#" class="submenu">staff three</a>
            </div>
        <a class="menu1" onclick="showHide('menu3')">services</a>
            <div id="menu3" class="hide">
                <a href="#" class="submenu">services one</a>
                <a href="#" class="submenu">services two</a>
                <a href="#" class="submenu">services three</a>
                <a href="#" class="submenu">services four</a>
            </div>
        <a class="menu1" onclick="showHide('menu4')">projects</a>
            <div id="menu4" class="hide">
                <a href="#" class="submenu">project one</a>
                <a href="#" class="submenu">project two</a>
                <a href="#" class="submenu">project three</a>
                <a href="#" class="submenu">project four</a>
                <a href="#" class="submenu">project five</a>
            </div>
        <a class="menu1" onclick="showHide('menu5')">contact</a>
            <div id="menu5" class="hide">
                <a href="#" class="submenu">Link One here</a>
            </div>
Any help much appreciated
__________________
Print & Web Design
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 15-04-2006, 05:23 PM
louie's Avatar
Senior Member
 
Join Date: Jan 2006
Location: Dublin, Ireland
Posts: 2,006
Nominated 5 Times in 3 Posts
TOTW/F/M Award(s): 0
louie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud of
Send a message via Yahoo to louie Send a message via Skype™ to louie
Default

you need to look into something with onmouseover and onmouseout.

check this out:

http://www.milonic.com/download.php?sampleid=2
__________________
:. Web Design & Development Web Design Ireland
:. Search Engines Optimization Search Engines Optimization
:. Directory Submission Directory Submission
:. News & Press Release Ireland GiveItSocks.com
:. Used Cars Ireland, Car Parts & Car Audio Cars For Sale, Car Parts & Accessories
:. I Have 2 Find It Directory SEF Directory
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 15-04-2006, 09:27 PM
ButtermilkJack's Avatar
Wannabe Geek
 
Join Date: Feb 2006
Location: Dublin, Ireland
Posts: 265
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
ButtermilkJack will become famous soon enough
Default

Hey louie, thanks for the pointer, but I actually need the submenu that the user clicks to stay open while they browse the current page (as it does now) but any other open submenus to close, if you follow.

Any ideas?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 15-04-2006, 09:53 PM
louie's Avatar
Senior Member
 
Join Date: Jan 2006
Location: Dublin, Ireland
Posts: 2,006
Nominated 5 Times in 3 Posts
TOTW/F/M Award(s): 0
louie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud of
Send a message via Yahoo to louie Send a message via Skype™ to louie
Default

Quote:
Originally Posted by ButtermilkJack
Hey louie, thanks for the pointer, but I actually need the submenu that the user clicks to stay open while they browse the current page (as it does now) but any other open submenus to close, if you follow.

Any ideas?
you can do this by using request.querystring (ASP) or $_REQUEST (PHP)

take a look at this - http://www.eire-webdesign.ie/templat...t.asp?pageid=2

no Javascript involved.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 16-04-2006, 05:59 PM
ButtermilkJack's Avatar
Wannabe Geek
 
Join Date: Feb 2006
Location: Dublin, Ireland
Posts: 265
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
ButtermilkJack will become famous soon enough
Default

I just found this. 'Single branch opening' was what I was looking for apparantly
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
javascript or css, menu

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT +1. The time now is 12:11 AM.


Powered by: vBulletin Version 3.7.3, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
Hosted in Ireland by Blacknight - Test your ISP |Irish Hosting Directory| Armchair.ie|Logo by Eden Web Design|Avatars by Afterglow |Latest Blog Entries | VPS HostingAd Management by RedTyger

Search Engine Friendly URLs by vBSEO 3.2.0