Javascript: Show/Hide block with <div>

sasi510

New Member
Messages
6
Reaction score
0
Points
0
put the below code between ur <head></head> tags

<script language="javascript">
<!-- ////////////////////////////////////////// Show/Hide Script ////////////////////////

var state = 'none';

function showhide(layer_ref) {

if (state == 'block')
{
state = 'none';
}
else
{
state = 'block';
}
if (document.all)
{ //IS IE 4 or 5 (or 6 beta)
eval( "document.all." + layer_ref + ".style.display = state");
}
if (document.layers)
{ //IS NETSCAPE 4 or below
document.layers[layer_ref].display = state;
}
if (document.getElementById &&!document.all)
{
hza = document.getElementById(layer_ref);
hza.style.display = state;
}


}

</script>


Then put the following href link with div tag to show or hide your specific content

<p><a href="#" onclick="showhide('div1');">show/hide me</a></p>
<div id="div1" style="display: none;">
////////////// your content goes here ////////////////////
<table width="200" border="0">
<tr>
<td><input name="un" type="text" /></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>show me</td>
<td>show me</td>
</tr>
</table>
////////////////// End of your Content /////////////////////////
</div>

Good luck,
- Sasi
 
Top