PDA

View Full Version : Help with Navigation Menu



javanewbie7
02-20-2012, 09:06 PM
I'm trying to learn to write javascript myself. So please, don't right anything for me, just steer me in the right direction.

The way I have my my navigation set up is when the user clicks on a section of the main nav, the subnav displays beneath the header (see the pic more a visual idea).

http://beauwaldrop.com/images/mockup.jpg

I want the the subnav for "Services" to be displayed on all pages that are listed under Services. Same thing for everything else on the nav bar.

They way it's set up right now, the "about" submenu is displayed on every page. If the user clicks on "services" then that submenu displays. Just in case you need it, I'm posting the code for that. Like I said above, please don't write anything for me, just point me in the right direction.


/*Javascript to display Sub Menu */

function showAbout() {
if(subnav.style.display=="none") {
subnav.style.display="block";
services.style.display="none";
contact.style.display="none";;
partners.style.display="none";
}
else subnav.style.display="none";
}
function showServices() {
if(services.style.display=="none"){
services.style.display="block";
subnav.style.display="none";
contact.style.display="none";
partners.style.display="none";
}
else services.style.display="none";
}
function showContact() {
if(contact.style.display=="none"){
contact.style.display="block";
subnav.style.display="none";
services.style.display="none";
partners.style.display="none"
}
else contact.style.display="none";
}
function showPartners() {
if(partners.style.display=="none"){
partners.style.display="block";
subnav.style.display="none";
services.style.display="none";
contact.style.display="none";
}
else partners.style.display="none";
}

c1lonewolf
02-21-2012, 07:47 PM
use 'location'
if 'current location' contains the word LowerCase('services') then show services menu one function will work with all pages and directories.