I’m trying to put together this expandable menu that runs sql (using javascript and php). I’ve got the code below but I’m horrible with javascript and I can’t get two things to work.
I cannot figure out how to use the closall() function so that when the page opens all selections are closed.
I’m trying to get the mouseover colors and clickable areas and the only way I know how to do that is with a table so I thought I’d put a quick table in between the <li> but can’t figure out the whole onClick= to incorporate the # so that I can get rid of the <a href> tag part…
<?php
require("connect.php");
$connectmysql = mysql_connect($host,$user,$password) or die ($cantconnectmysqlmessage);
$db = mysql_select_db($database,$connectmysql) or die ($cantconnectdatabasemessage);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Remarks</title>
<script type="text/javascript" language="javascript1.3">
<!--
function closeall()
{
var divs=document.getElementsByTagName('div')
for(var i=0; i<divs.length; i++)
divs[i].style.display='none';
}
function clicked(element)
{
var div=document.getElementById(element)
if(div.style.display=='none')
div.style.display='block';
else
div.style.display='none';
return;
}
// -->
</script>
<link href="../HighVisibility/dstyles.css" rel="stylesheet" type="text/css" />
</head>
<body LEFTMARGIN="0" TOPMARGIN="0" MARGINWIDTH="0" MARGINHEIGHT="0">
<div id='PageTop'>
<div id='NavLogo'></div>
<span id='ETranText'><!--<img src="images/MAXXFORCE_LOGO.png" border='0'></img>--></span></div>
<div id='PageTopBottom1'></div>
<div id='PageTopBottom2'></div>
<div id='PageTopBottom3'></div>
<div style='position: absolute; top: 145px; left: 10px;'>
<ul type="disc">
<?php
$Disp1Query = "SELECT DISTINCT PREFIX FROM tblcr2md WHERE PREFIX <> '' ORDER BY PREFIX";
$Disp1Result = mysql_query($Disp1Query) or die(mysql_error().'<br />'.$Disp1Query);
while ($Row1 = mysql_fetch_assoc($Disp1Result))
{
$SupplierCode = $Row1["PREFIX"];
echo"<li><table width=100%><tr><td style=\\"Cursor:Hand\\" onClick=\\"clicked('".$SupplierCode."')\\" onMouseOver=\\"this.style.backgroundColor='#E4E7FF';\\" onMouseOut=\\"this.style.backgroundColor='#FFFFFF';\\" ><a href=\\"#\\" onClick=\\"clicked('".$SupplierCode."')\\">".$SupplierCode."</a></td></tr></table></li>";
echo"<div id='".$SupplierCode."'>";
echo"<ul type='square'>";
$Disp2Query = "SELECT DISTINCT NAV_PN FROM tblcr2md WHERE PREFIX = '".$SupplierCode."' ORDER BY NAV_PN";
$Disp2Result = mysql_query($Disp2Query) or die(mysql_error().'<br />'.$Disp2Query);
while ($Row2 = mysql_fetch_assoc($Disp2Result))
{
echo"<li>".$Row2["NAV_PN"]."</li>";
}
echo"</ul>";
echo"</div>";
}
?>
</body>
</html>