Hey, you can simply make use of the following code for creating dynamic dropdown list. I am not having knowledge of jsp, so you can simply use logic behind it:
Code:
function dynamictree($rootempid,$level)
{
$sql="select empid,emp_name
from tbl_name
where deptid=$rootempid
order by emp_name";
$result=mysql_query($sql);
while (list($DBempid,$dbempname)=mysql_fetch_row($result))
{
$width=($level+1)*24;
if ($width==48)
$display=" ";
if ($width==72)
$display=" ";
if ($DBempid==1)
{
$display.="<option value=$DBempid>";
}
else
{
$display.="<option value=$DBempid>";
}
$display.="$dbempname</option>";
echo $display;
dynamictree($DBempid,$level+1);
}
}
?>
<table cellpadding="2" cellspacing="2" border="0" width="width="100%"">
<tr>
<td><select name="">
<? dynamictree(0,0);?>
</select></td>
</tr>
</table>
Bookmarks