I have some divs on my page that when a link is clicked they need to toggle (show/hide)
JS
var state = 'none';
function showhide(layer_ref) {
//alert(eval( "document.all." + layer_ref + ".style.display") == "none")
if (document.all) { //IS IE 4 or 5 (or 6 beta)
if(eval( "document.all." + layer_ref + ".style.display") == "none"){
eval( "document.all." + layer_ref + ".style.display = 'block'");
}else{
eval( "document.all." + layer_ref + ".style.display = 'none'");
}
}
if (document.layers) { //IS NETSCAPE 4 or below
if(document.layers[layer_ref].display == none){
document.layers[layer_ref].display = "block";
}else{
document.layers[layer_ref].display = "none";
}
}
if (document.getElementById &&!document.all) {
if(document.getElementById(layer_ref).style.display == "none"){
document.getElementById(layer_ref).style.display = "block";
}else{
document.getElementById(layer_ref).style.display = "none";
}
}
}
HTML
<div class="faq-row" style="z-index: 976;">
<span class="itp-title"><a href="#" onclick="showhide('div1');">title</a></span>
<div id="div1" style="display: none;">divcont</div>
</div>
<div class="faq-row" style="z-index: 976;">
<span class="itp-title"><a href="#" onclick="showhide('div1');">title</a></span>
<div id="div2" style="display: none;">divcont</div>
</div>
<div class="faq-row" style="z-index: 976;">
<span class="itp-title"><a href="#" onclick="showhide('div1');">title</a></span>
<div id="div3" style="display: none;">divcont</div>
</div>
my problem is that no matter what link i click it only toggles the first div? Cany anybody see where im going wrong? Thanks