...

View Full Version : Show/Hide DIV probelm



emanuelle
05-08-2006, 01:43 PM
I would like to change some features of this script:
The checkbox is the one who shows and hides the div.

The div has to be closed when the page loads.
The row of the checkbox (bgcolor="#808080") has to change color when it shows the content of DIV (becomes #efefef)
Has to work in Explorer and FF
Can anyone help pls

<script type="text/javascript">
function ShowHide(obj, visibility) {
if(document.getElementById){
divs = document.getElementsByTagName("div");
divs[obj].style.visibility = visibility;
}
}
</script>

<table>

<tr>
<td bgcolor="#808080"><input type="checkbox" value="" onclick="ShowHide('lyr1','visible')">
<a href="#" onclick="ShowHide('lyr1','hidden')">hide</a><br/></td>
</tr>
<div id="lyr1">lyr1</div>
</table>

MikoLone
05-08-2006, 10:59 PM
<script type="text/javascript">
function ShowHide(show, obj ) {

if(show){
document.getElementById(obj).style.display = 'block'; //or inline whatever
}else{
document.getElementById(obj).style.display = 'none';
}
document.getElementById('checkBoxCell').style.backgroundColor = "#efefef";
}
</script>

<table>

<tr>
<td bgcolor="#808080" id="checkBoxCell"><input type="checkbox" id="checky" onclick="ShowHide(this.checked, 'lyr1');"><label for="checky">hide</label><br/></td>
</tr>
<div id="lyr1" style="display:none;">lyr1</div>
</table>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum