Jump to content


Photo

best way to go about making this sublink navigation?


  • Please log in to reply
3 replies to this topic

#1 Clandestine

Clandestine

    * Forum Police *

  • Members
  • PipPipPip
  • 833 posts
  • Gender:Male
  • Location:Redondo Beach, CA

Posted 29 October 2008 - 01:53 AM

Ok on my website that I finally got working in the browsers.

I want to add a sublink area under the banner in the greenish color bar. So if someone hovers over the main navigation buttons and it has sublinks they will show here.

http://www.clandesti...rance/index.php

How hard would this be to achieve?

I've seen tutorials about the vertical subnav menu, but what about horizontal?

Thanks a bunch!

#2 Matt L

Matt L

    Young Padawan

  • Members
  • Pip
  • 272 posts
  • Gender:Male
  • Location:Newcastle

Posted 29 October 2008 - 10:52 AM

The way I'd do this would be with a bit of Javascript. Add this to the Head of you page.
<script language="javascript" type="text/javascript">
<!--
function showorhide(id) {
if (document.getElementById(id).style.display == "none") {
document.getElementById(id).style.display = "block";
} else {
document.getElementById(id).style.display = "none";
}
}
-->
</script>
Then on your links you could have:
<a href="#" onclick="showorhide('subnav1'); ">Link 1</a>
<a href="#" onclick="showorhide('subnav2'); ">Link 2</a>
<a href="#" onclick="showorhide('subnav3'); ">Link 3</a>
Where you have:
<div id="subnav1" style="display:none; ">Sub navigation links</div>
<div id="subnav2" style="display:none; ">Sub navigation links</div>
<div id="subnav3" style="display:none; ">Sub navigation links</div>
That should do the trick for you :)

#3 Clandestine

Clandestine

    * Forum Police *

  • Members
  • PipPipPip
  • 833 posts
  • Gender:Male
  • Location:Redondo Beach, CA

Posted 29 October 2008 - 11:32 AM

Thanks, this is what I wanted, but the sublinks don't clear when I click a different link. They just add up.
I uploaded the site so you can see what I am talking about

Thanks!!

Edited by Clandestine, 29 October 2008 - 12:23 PM.


#4 rc69

rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 02 November 2008 - 08:03 PM

In the showorhide() function, you need to hide the previously opened submenu. The easiest way to do this is either a variable that keeps track of the last opened one, or a loop that will go through every submenu until it finds the open one and hides it (easiest way to get a list of all the submenus is to make a container div to group them all together).




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users