S
Satish.Talyan
hi,
i want to create a dynamic tree hierarchy in javascript.there are two
parts in tree, group & user.when we click on group then users come
under that's tree category will be opened.problem is that i am not able
to arrange three things simultaneously,group,users & there
functionality simultaneously.dynamic means group & users come from
database and groups & users can be increased in number at any time. i
am sending code for that tree along with this mail.plz kindly get it
attached with mail.plz help me to shootout this problem.
thankyou.
<?php
require($_SERVER['DOCUMENT_ROOT']."/includes/settings.inc.nmp");
require(NMP_WEBROOT_PATH."/includes/common_functions.inc.nmp");
$sql3="Select groupid,groupname FROM tblgroup";
$iResult3=$dbConn->ExecuteSelectQuery($sql3,$rsRes3,$iret_rows3);
?>
<TABLE align="center" width="600" border="1">
<tr>
<td colspan="0" class="DisplayHeader" align="center"><font
size="1.5">Group</font></td>
</td>
<td colspan="0" class="DisplayHeader" align="center"><font
size="1.5">Firewall Rule</font></td>
</td>
</tr>
<TD valign="top">
<TABLE width="125" border="0">
<TD>
<html>
<head>
<title>JavaScript Tree Control</title>
<style>
body{
font: 10pt Verdana,sans-serif;
color: navy;
}
.trigger{
cursor: pointer;
cursor: hand;
}
.branch{
display: none;
margin-left: 35px;
}
x=new array(30);
y=new array(30);
var i=0;
</style>
<script language="JavaScript">
var openImg = new Image();
openImg.src = "open.gif";
var closedImg = new Image();
closedImg.src = "closed.gif";
function showBranch(branch)
{
var objBranch = document.getElementById(branch).style;
if(objBranch.display=="block")
objBranch.display="none";
else
objBranch.display="block";
swapFolder(branch);
}
function swapFolder(img)
{
objImg = document.getElementById(img);
if(objImg.src.indexOf('closed.gif')>-1)
objImg.src = openImg.src;
else
objImg.src = closedImg.src;
}
</script>
</head>
<?php
while($arRes2=$dbConn->GetData($rsRes3))
{
?>
<div>
<class="trigger"
onClick="showBranch('x[i++]');
swapFolder('y[i++]')">
<INPUT TYPE=checkbox NAME=chkbx VALUE="" >
<img src="userimg3.gif" border="0"
id="y[i++]"><font size="1.5">
<?php echo $arRes2['groupname'];?></font>
</div>
<span class="branch" id="x[i++]">
<?php
$sql1="Select username FROM tbluser where groupname
='$arRes2[groupname]'";
$iResult1=$dbConn->ExecuteSelectQuery($sql1,$rsRes1,$iret_rows1);
while($arRes=$dbConn->GetData($rsRes1))
{
?>
<input type=checkbox name=SelMsg1 value="" e[0]><img
src="userimg2.gif"><font size="1.5">
<?php echo $arRes['username'];?></font><br>
<?php
}
?>
</span>
<?php
}
?>
i want to create a dynamic tree hierarchy in javascript.there are two
parts in tree, group & user.when we click on group then users come
under that's tree category will be opened.problem is that i am not able
to arrange three things simultaneously,group,users & there
functionality simultaneously.dynamic means group & users come from
database and groups & users can be increased in number at any time. i
am sending code for that tree along with this mail.plz kindly get it
attached with mail.plz help me to shootout this problem.
thankyou.
<?php
require($_SERVER['DOCUMENT_ROOT']."/includes/settings.inc.nmp");
require(NMP_WEBROOT_PATH."/includes/common_functions.inc.nmp");
$sql3="Select groupid,groupname FROM tblgroup";
$iResult3=$dbConn->ExecuteSelectQuery($sql3,$rsRes3,$iret_rows3);
?>
<TABLE align="center" width="600" border="1">
<tr>
<td colspan="0" class="DisplayHeader" align="center"><font
size="1.5">Group</font></td>
</td>
<td colspan="0" class="DisplayHeader" align="center"><font
size="1.5">Firewall Rule</font></td>
</td>
</tr>
<TD valign="top">
<TABLE width="125" border="0">
<TD>
<html>
<head>
<title>JavaScript Tree Control</title>
<style>
body{
font: 10pt Verdana,sans-serif;
color: navy;
}
.trigger{
cursor: pointer;
cursor: hand;
}
.branch{
display: none;
margin-left: 35px;
}
x=new array(30);
y=new array(30);
var i=0;
</style>
<script language="JavaScript">
var openImg = new Image();
openImg.src = "open.gif";
var closedImg = new Image();
closedImg.src = "closed.gif";
function showBranch(branch)
{
var objBranch = document.getElementById(branch).style;
if(objBranch.display=="block")
objBranch.display="none";
else
objBranch.display="block";
swapFolder(branch);
}
function swapFolder(img)
{
objImg = document.getElementById(img);
if(objImg.src.indexOf('closed.gif')>-1)
objImg.src = openImg.src;
else
objImg.src = closedImg.src;
}
</script>
</head>
<?php
while($arRes2=$dbConn->GetData($rsRes3))
{
?>
<div>
<class="trigger"
onClick="showBranch('x[i++]');
swapFolder('y[i++]')">
<INPUT TYPE=checkbox NAME=chkbx VALUE="" >
<img src="userimg3.gif" border="0"
id="y[i++]"><font size="1.5">
<?php echo $arRes2['groupname'];?></font>
</div>
<span class="branch" id="x[i++]">
<?php
$sql1="Select username FROM tbluser where groupname
='$arRes2[groupname]'";
$iResult1=$dbConn->ExecuteSelectQuery($sql1,$rsRes1,$iret_rows1);
while($arRes=$dbConn->GetData($rsRes1))
{
?>
<input type=checkbox name=SelMsg1 value="" e[0]><img
src="userimg2.gif"><font size="1.5">
<?php echo $arRes['username'];?></font><br>
<?php
}
?>
</span>
<?php
}
?>