I have made little changes to your code and posted here the corrected one. The problem seems to be the '\' escape character that you used, which is not required in your case. The changes are marked with red colour.

Code:
<html>

<head>
<title>Sample Page</title>
<script type="text/javascript">
function toggleVisiblity()
{
  var name1="eg";
 
    var tbl = document.getElementById("chart");
    alert(tbl);
    alert(tbl.style.display);
    alert(tbl.nodeName);
    var clink=document.getElementById("chartlink");

    if(tbl!=null){
    if (tbl.style.display == 'block')
    {
        tbl.innerHTML="";
        tbl.style.display = 'none';
        
    }
    else
    {
        tbl.innerHTML="<img src=../images/" + name1 + ".png>";
        tbl.style.display = 'block';
     
    }
    }
}
</script>
</head>

<body>
<div align=left>
<a id='chartlink' href=# onclick="toggleVisiblity()"><img src="../images/chart.gif" border=0></a>
</div>
<div id='chart' style='display:none;' align=center>
</div>
</body>

</html>
Let me know whether this works or not.

Last edited by venami; 13Jan2010 at 11:53.. Reason: Highlighted the changed part in red.