...

View Full Version : how to collapse some menus, not all



Leafgreen
07-29-2008, 08:48 AM
I have a hierarchical menu. Right now all subfolders/submenus are expanded. I want *some* not all of the menu folders by default to be collapsed/closed. How? :confused:
I have attached a .jpg of the menu as it appears now.
Here is the code:

<script type="text/javascript" src="js/dtree.js" ></script>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr >
<td height="1" align="left" valign="middle" ><img src="images/blank.gif" alt=" " width="1" height="1" /></td>
</tr>
<tr bgcolor="">

<td height="20" align="center" valign="middle" bgcolor="#FFFFFF" bordercolor="#FF6633" class="item-heading" style="padding-left:5px;">
<td>
</tr>
<tr>

<td align="left" valign="top">
<?
if($_SESSION['admin'] == 1 ) {
?>
<?
}
?>
<DIV class=dtree style="width: 190px;">
<!-- <a class="node" href="javascript: d.openAll();">Open all&nbsp;</a> || <a class="node" href="javascript: d.closeAll();">&nbsp;Close all</a> -->
<script type="text/javascript">
d = new dTree('d');
d.add(0,-1,'<B>Admin Panel</B>','welcome.php');
<?
if($_SESSION['admin_name']=='admin') {
recurcive(0);
?>
d.add(99,0,'Exit','logout.php');
d.add(100,99,'Logout','logout.php');
<?
}
else {
?>
d.add(500,0,'My Account','edit_admin_user.php?id=<?= $_SESSION['admin'] ?>&subadmin=1');
d.add(501,500,'Edit Account','edit_admin_user.php?id=<?= $_SESSION['admin'] ?>&subadmin=1');
<?
recurcive1(0);
?>
d.add(99,0,'Exit','logout.php');
d.add(100,99,'Logout','logout.php');
<?
}
?>
<?
function recurcive($id)
{
$q=mysql_query("SELECT * FROM tbl_menu_master WHERE parent_id ='".$id."' order by menu_id");
$n=mysql_num_rows($q);

while($r=mysql_fetch_array($q))
{
?>
d.add(<? print $r[menu_id]?>,<? print $r[parent_id]?>,'<? print $r[menu_name] ?>','<? print $r[menu_url] ?>');
<?
recurcive($r[menu_id]);
}
}
function recurcive1($id)
{
$q=mysql_query("SELECT m.menu_name,m.parent_id,m.menu_id,m.menu_url,m.image,p.admin_id FROM tbl_menu_master m
left join tbl_admin_permission_master p
on m.menu_id=p.menu_id WHERE p.admin_id=".$_SESSION['admin']." and m.parent_id =".$id." order by m.menu_id") or die(mysql_error());

$n=mysql_num_rows($q);

while($r=mysql_fetch_array($q))
{
?>
d.add(<? print $r[menu_id]?>,<? print $r[parent_id]?>,'<? print $r[menu_name] ?>','<? print $r[menu_url] ?>');
<?
recurcive1($r[menu_id]);
}
}
?>
document.write(d);

FYI, tbl_menu_master has nothing that controls whether the folder is expanded or collapsed.
TIA!:thumbsup:
Leafgreen

abduraooft
07-29-2008, 08:51 AM
Could you post a link to your page? we can't parse and reproduce your menu at our end.

Leafgreen
07-29-2008, 08:53 AM
Oh dang, no. It's in an admin area that I can't provide access to. What should I do?

abduraooft
07-29-2008, 08:58 AM
You can save the page as html and upload the necessary scripts and CSS. Or just create a simple demo page and give us a link.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum