
December 30th, 2003, 10:06 AM
|
Registered User
|
|
Join Date: Dec 2003
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
automatically closing a folder when others are clicked
i am having a hard time revising the code to automatically close the other folders when another folder is clicked. right now, they all remain open and requires reclicking to close. any help is appreciated! :D thank you!
/nurraj
--------------------------------------------------------------------
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style>
<!--
#foldheader{
cursor:pointer;
cursor:hand;
font-weight:bold;
margin: 0;
padding: 0;
list-style-type: none;
font-size: xx-small;
line-height: 9pt;
}
#foldinglist{
margin: 0;
padding: 0;
list-style-type: none;}
//-->
</style>
<script language="JavaScript1.2">
<!--
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=="foldheader")
iscontained=1
else
while (ns6&&cur.parentNode||(ie4&&cur.parentElement))
{
if (cur.id=="foldheader"||cur.id=="foldinglist"){
iscontained=(cur.id=="foldheader")? 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>
</head>
<body>
<font face="Arial" size="1">
<ul>
<li id="foldheader">FolderA</li>
<ul id="foldinglist" style="display:none" style=&{head};>
<li> <a href="http://www.x.com">x</a></li>
<li> <a href="http://www.y.com">y</a></li>
<li> <a href="http://www.z.com">z</a></li>
</ul>
<li id="foldheader">FolderB</li>
<ul id="foldinglist" style="display:none" style=&{head};>
<li> <a href="http://www.x.com">x</a></li>
<li> <a href="http://www.y.com">y</a></li>
<li> <a href="http://www.z.com">z</a></li>
</ul>
<li id="foldheader">FolderC</li>
<ul id="foldinglist" style="display:none" style=&{head};>
<li> <a href="http://www.x.com">x</a></li>
<li> <a href="http://www.y.com">y</a></li>
<li> <a href="http://www.z.com">z</a></li>
</ul>
<li id="foldheader">FolderD</li>
<ul id="foldinglist" style="display:none">
<li> <a href="http://www.x.com">x</a></li>
<li> <a href="http://www.y.com">y</a></li>
<li> <a href="http://www.z.com">z</a></li>
</ul>
</ul>
</font>
</body>
</html>
|