Remortgages - Repair Bad Credit - Actress - Car Loan - Montana Music

PDA

View Full Version : I need javascript Help


mudassarahmad
Dec 1st 2007, 6:58 pm
In javascript how tree menu fixed when page refresh
Sample Code
FileName=left.php

<script language="javascript">
function menu_change(div,img,m17)
{
var_src=document.all(img).src;
var img_length=var_src.length
var index=var_src.indexOf('images');
var actual_name=var_src.substring(index,img_length);
if(actual_name=="images/menu_closed.gif")
{
document.all(img).src="images/menu_open.gif";
document.all(div).style.display="";
alert("Close");
}
if(actual_name=="images/menu_open.gif")
{
document.all(img).src="images/menu_closed.gif";
document.all(div).style.display="none";
alert("Open");
}

}
</script>
</head>
<?php
$disp_style;
if(isset($_GET['m17']))
{
$disp_style = "visible";
}
else
{
$disp_style = 'display:none';
}
?>
<body>
<link href="images/style.css" rel="stylesheet" type="text/css">
<table cellpadding=0 cellspacing=0 border=0 width=180>
<tr><td>
<table cellpadding="0" cellspacing="0" border="0">
<tr>

<td width="180" height="4" align="left" bgcolor="#F7F7F7" onClick="javascript:menu_change('div_17','img_17','m17');" onMouseover="this.style.backgroundColor='white'" onMouseout="this.style.backgroundColor='#F7F7F7'"><a style="cursor:hand; "><img border=0 name="img_17" src="images/menu_closed.gif">&nbsp;<font face="verdana" size="1">Order</font><font face="verdana" size="1" style="text-decoration:none; ">
Management</font></a></td>
</tr>
<tr>
<td width=180 height="0" align="left">
<table cellpadding="0" id="div_17" cellspacing="0" style=<?php echo $disp_style; ?> border="0">
<tr>
<td width="20" style="border-bottom:1 dashed #CFCFCF; ">&nbsp;</td>
<td width="155" height="23" class="text" onMouseOver="this.style.fontWeight='bold'" onMouseout="this.style.fontWeight='normal'" style="border-bottom:1 dashed #CFCFCF; " valign="center"><img src="images/sub_item.gif">
<a style="text-decoration: none" href="new_order.php?m17=1">
<font face="verdana" size="1" color="#000000">Active Orders
</font></a></td>
</tr>
</table>
</td>
</tr>
</table>
</td></tr>
</table>

hrcerqueira
Dec 1st 2007, 7:57 pm
I think there's nothing wrong with the javascript (although the code looks a bit clumsy), the problem is here:


<table cellpadding="0" id="div_17" cellspacing="0" style=<?php echo $disp_style; ?> border="0">


When you assign values to $disp_style your not assigning the quotes, so, you must add them latter in the html code, like this:

<table cellpadding="0" id="div_17" cellspacing="0" style="<?php echo $disp_style; ?>" border="0">


Also, in this part of the code:


<?php
$disp_style;
if(isset($_GET['m17']))
{
$disp_style = "visible";
}
else
{
$disp_style = 'display:none';
}
?>


"visible" doesn't mean nothing, what your trying to do is "visibility: visible", but this has no effect on your script, just leave it empty.

Cheers