
March 18th, 2003, 01:54 PM
|
|
Junior Member
|
|
Join Date: Jan 2003
Location: South East England
Posts: 10
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
having the Internet only expanding menu start off collapsed problems?????
hi i have been playing around with the collapsing menu off this site found Here
ive just changed the sql query to fit in with my data base. but the problem i am having is that the menu starts off all expanded but i want it to start off coollapsed.
i tried putting in an onload function to change it as soon as it loads but when it loads for the second time it calls the onload function etc.. never ending circle..
any ideas i dont use javascript much
regards
jon
ps here is the code i have so far
PHP Code:
<?php
// Create our database connection
$sqlConn = mysql_connect("localhost", "root", "HJ34Rtf") or die("Couldn't connect to database");
$dbConn = mysql_select_db("compsci", $sqlConn) or die("Couldn't connect to database");
//set up
$sql = "select Distinct staff.StaffCode, tutors.TutorID
from staff, tutors, students
where staff.StaffID = tutors.StaffID
and students.TutorID = tutors.TutorID
and students.Year >= 11
order by StaffCode ASC;";
$nodeResult = mysql_query($sql) or die("SELECT query failed". mysql_error());
$counter = 0;
?>
<html>
<head>
<title> Dynamic Menus </title>
<style>
.root_td
{
background-color: #000000;
color: #FFCF00;
font-family: Verdana;
font-size: 8pt;
font-weight: bold;
height: 22;
padding-left: 5;
}
.child_td
{
background-color: #D1D1D1;
color: #000000;
font-family: Verdana;
font-size: 8pt;
font-weight: bold;
text-decoration: underline;
height: 22;
padding-left: 10;
padding-right: 10;
padding-bottom: 3;
}
body
{
color: #000000;
font-family: Verdana;
font-size: 8pt;
font-weight: normal;
}
a
{
color: #000000;
}
</style>
<script language="JavaScript">
function ToggleNode(nodeObject, imgObject)
{
if(nodeObject.style.display == '' || nodeObject.style.display == 'inline')
{
nodeObject.style.display = 'none';
imgObject.src = 'plus.gif';
}
else
{
nodeObject.style.display = 'inline';
imgObject.src = 'minus.gif';
}
}
</script>
</head>
<body bgcolor="#FFFFFF">
<table width="250" border="0" cellspacing="0" cellpadding="0">
<?php
while($node = mysql_fetch_array($nodeResult))
{
?>
<tr>
<td class="root_td">
<img id="img_root_<?php echo $counter; ?>" onClick="ToggleNode(td_root_<?php echo $counter; ?>, img_root_<?php echo $counter; ?>)" border="0" src="minus.gif">
<?php echo $node[0]; ?>
</td>
</tr>
<tr>
<td id="td_root_<?php echo $counter++; ?>" class="child_td">
<table width="100%">
<?php
$sql = "select * from Students where TutorID = {$node[1]} order by Forename asc";
@$childResult = mysql_query($sql);
while($child = mysql_fetch_row($childResult))
{
?>
<tr>
<td class="child_td">
<a href="<?php echo $child[2]; ?>"><?php echo "$child[1] $child[2]"; ?></a>
</td>
</tr>
<?php
}
?>
</table>
</td>
</tr>
<?php
}
?>
</table>
</body>
</html>
|