...

View Full Version : adapt this for multiple div's



urgido
08-10-2006, 11:50 AM
function ToggleNav() {
if (document.getElementById('nav').style.display=='none') {
document.getElementById('nav').style.display='';
document.getElementById('hide').style.display='';
document.getElementById('show').style.display='none';
} else {
document.getElementById('nav').style.display='none';
document.getElementById('hide').style.display='none';
document.getElementById('show').style.display='';
}
}

I have the that code but I want to adatp this code for multiple div's (like id="nav1", id="nav2"........) How I can make that?

Best Regards

vwphillips
08-10-2006, 12:22 PM
<html>
<head>
<script type="text/javascript">
function ToggleNav(zxcgrp,zxcid){
var zxcobj=document.getElementById(zxcid)
if (!window[zxcgrp]){ window[zxcgrp]=null; }
if (window[zxcgrp]){ if (window[zxcgrp]!=zxcobj){ window[zxcgrp].style.display='none'; } }
zxcobj.style.display=(zxcobj.style.display=='none')?'':'none';
window[zxcgrp]=zxcobj;
}
</script>

</head>
<body>
<input type="button" name="" value="Show 123" onclick="ToggleNav('grp1','main');"/>
<input type="button" name="" value="Show ABC" onclick="ToggleNav('grp1','results');" />

<div id="main" style="display:none;" >123</div>
<div id="results" style="display:none;">ABC</div>
<br />
<br />
<input type="button" name="" value="Show 123" onclick="ToggleNav('grp2','main1');"/>
<input type="button" name="" value="Show ABC" onclick="ToggleNav('grp2','results1');" />

<div id="main1" style="display:none;" >123</div>
<div id="results1" style="display:none;">ABC</div>
</body>
</html>

urgido
08-10-2006, 12:43 PM
Thank's That Works!

urgido
08-10-2006, 01:00 PM
mmm... But I how do I leave the phrase "HIDE" to hide and "SHOW" to show?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum