Click to See Complete Forum and Search --> : 'style.display' is null or not an object


breeb
07-08-2003, 08:04 AM
I am pretty new to Javascript and trying to display a result set from a database when the user clicks on a word. My javascript function is:
<SCRIPT>
function toggle(e)
{
if (e.style.display == "none")
{
e.style.display = "";
}
else
{
e.style.display = "none";
}

}
</SCRIPT>

and the relevant parts of my html code are:

<div style = "cursor: hand" onClick = "toggle(document.all.HideShow);">
View
</div>

<span style = "colour: blue" id = HideShow>
**the data that I want to display**
</span>

I am using IE 5.5, however this code would need to run on various different versions.

Any help??

Khalid Ali
07-08-2003, 09:22 AM
Wondering why wouls you have display as
e.style.display = "";
try using some CSS value here such as

e.style.display = "block"

breeb
07-09-2003, 04:31 AM
Using

<div style = "cursor: hand" onClick = "toggle(document.getElementById('HideShow'));">

corrects the problem. However, i am using a nested table when clicking on 'view' for ANY of the rows in the table the data in the FIRST row is displayed/hidden. Also I realised that I would not like the data to be displayed unless the user clicked on 'View' (at the moment the data is automatically displayed and then hidden when 'View' clicked on).

Any ideas?!!