Click to See Complete Forum and Search --> : Tree menu


Motabobo
05-09-2003, 06:45 PM
Hi !

I'm trying to generate a tree menu based on the directory structure of my website.

The only working code i have found so far is the one submitted by Stephane Piazza at Planet Source Code :
Link (http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=6331&lngWId=4)

Unfortunately, that script won't work with Netscape and i need it to work with Netscape 6 + (i won't bother with NN4).

Any help would be greatly appreciated !!!
I guess the easy way would be to modify the javascript that goes along with it !

Please help !

Thanks

hairynugs
05-10-2003, 12:48 AM
play around with this

function toggleMenu(obj){
if(document.getElementById){
objMenu=document.getElementById(obj).style
if(objMenu.display=="block"){
objMenu.display="none"
}else{
objMenu.display="block"
}return false
}else{
return true
}}

Motabobo
05-10-2003, 08:52 AM
Hello again !

I've modified the javascript as dave suggested me in the javascript forum.

So here is what i now use :
-------------------------------------------------------------------
function swapTree(menuDiv,fol)
{
window.focus();
d = document.getElementById(menuDiv);
i = document.images["img_"+menuDiv];
i1 = document.images["img_"+fol];
if (d.style.display=="none")
{
d.style.display="block";
i.src='../img/minus.gif';
i1.src='../img/foldero.gif';
}
else
{
d.style.display="none";
i.src='../img/plus.gif';
i1.src='../img/folder.gif';
}

}
-------------------------------------------------------------------

Unfortunately, it acts strangely under Netscape. As soon as you open one sub-level, instead of showing the line.gif, it shows the folder's gifs !!!

Take a look at my example :

http://www21.brinkster.com/rouxjean/explorer/tree/index.htm

For example, click on the css folder and then on the default subfolder. Under IE, everythig is fine but under Netscape, a folder icon will appear the the very left of the subfolder link !

Here is what i use in ASP to draw the menu (folders script) :
============================================

for Each folder in folders
Randomize
rndNb = CStr(Int((50 * Rnd) + 1) )
name = folder.Name
aff = Replace ("_"," ",name)
Response.Write "<!-- BEGIN MENU -->"
Set tmpRoot = fso.GetFolder(folder.Path)
Set tmpFiles = tmpRoot.files
tmpAff = foundLaunchDirectly(tmpFiles, launchDirectly)
if level > 0 Then
For cpt=1 to level
Response.Write "<img name='img_div"+name+"1' src='../img/line.gif' border=0 align='absmiddle' ><img name='img_div"+name+"1' src='../img/space.gif' border=0 align='absmiddle' >"
Next
End If

if ( tmpAff <> "") Then
Response.Write "<a href='"+tmpAff+"' target='screen' onClick=swapTree('div"+name+"_"+rndNb+"','div"+name+"1');>"
else
Response.Write "<a href='#' target='' onClick=swapTree('div"+name+"_"+rndNb+"','div"+name+"1');>"
End If
Response.Write "<img name='img_div"+name+"_"+rndNb+"' src='../img/plus.gif' border=0 align='absmiddle'><img name='img_div"+name+"1' src='../img/folder.gif' border=0 align='absmiddle' >"+aff+"</a><br>"

Response.Write "<div id='div"+name+"_"+rndNb+"' "

'Response.Write "<div id='div"+name+"_"+folder.ParentFolder.ShortName+"' "
Response.Write " style='z-index:3;display: none; margin-left:"
Response.Write posX
Response.Write "px' align='left'>"

Recurse folder.Path, posX, (level+1)
cpt = cpt + 1
Response.Write "</div>"
Response.Write "<!-- END MENU -->"

Next
============================================

Any help would be greatly appreciated !!!