Forum Moderators: open

Message Too Old, No Replies

Need help with expanding and collapsing menu

menu collapses when a link is clicked.

         

supermanjnk

1:06 am on Nov 25, 2004 (gmt 0)

10+ Year Member



I'm trying to make it so that when you click on one of the links the menu stays expanded when you click on a link, currently when you click on the link, it will simply collapse back on itself, instead of staying expanded.
my current set up is a page with an included menu, so the menu is included on each page, whats the best way to pass the current state of the menu onto the next page so it will stay expanded.
Javascript

<script language ="javascript">
var head = "display:''"
var ns6 = document.getElementById &&!document.all
var ie4 = document.all && navigator.userAgent.indexOf("Opera") == -1
function checkcontained(e)
{
var iscontained=0
cur = ns6? e.target : event.srcElement
i = 0
if (cur.id == "heading")
{
iscontained = 1
}
else
while(ns6 && cur.parentNode ¦¦ (ie4 && cur.parentElement))
{
if (cur.id == "heading" ¦¦ cur.id == "listing")
{
iscontained = (cur.id == "heading")? 1 : 0
break
}
cur = ns6? cur.parentNode : cur.parentElement
}
if (iscontained)
{
var foldercontent = ns6? cur.nextSibling.nextSibling : cur.all.tags("UL")[0]
if (foldercontent.style.display == "none")
{
foldercontent.style.display = ""
}
else
{
foldercontent.style.display = "none"
}
}
}
if (ie4 ¦¦ ns6)
document.onclick = checkcontained
</script>

HTML

<li id='heading'>Windows 2000</li>
<ul id='listing' style='display:none'>
<li id='listing'><a href="fakepath/fakefile.php">Introduction</a></li>
<li id='listing'><a href="fakepath/fakefile2.php">Installation</a></li>

DrDoc

7:23 pm on Nov 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, you can use a session (in PHP for example), or set a cookie... or control it with CSS...

The hint is that you need to pass something to the next page, or do some figuring on the target page.