Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to show a DIV block through Java script

Status
Not open for further replies.

meenu24

Programmer
May 5, 2006
37
US
Hi,

I am trying to show/hide a row in a table after checking a value.
THis is my code
<html>
<script>
function showDiv()
{
document.getElementById('imageDiv').style.display="block";
}
function hideDiv()
{
document.getElementById('imageDiv').style.display="none";
}
function init(var1)
{
if(var1 == 'novalue')
{
hideDiv()
}
else
{
showDiv()
}
}
</script>
<body onload="init('novalue')">
<table>
<div id ="imageDiv" style="position:absolute;display:none">
<td rowspan="4" align="top>somevalue</td>
</div>
</table>
</body>
</html>
As per the code the row td should not showup, when the page loads. But I can see the row. I am not sure what is wrong in my code.
Thanks for your time and suggestions

regards
 
You can't hide/show table cells like you are trying to do.
If you want to do something like this I suggest looking into the DOM's createElement(), setAttribute(), appendChild().

M. Brooks
 
Thanks Brooks,

I created a table inside the row then used the same code to hide it worked. Thankyou verymuch for your suggestions

regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top