Firstly, in the onclick procedure, you need to 'grab' (I'm sure there's a more technical name out there!) the layer you want to make visible/hidden:
Code:
var obj=document.getElementById(layer name)
Then from this you can set the style.display property:
Code:
obj.style.display="block";
Secondly, when making <a>'s point to javascript functions, I've always used a 'javascript://' in the href value. Then you use the onclicks (like you have) to carry out the javascript.
so my suggestion would be this:
HTML:
Code:
<p><a href="javascript://" onclick="show_layer(1)">Poetry</a> |
<a href="javascript://" onclick="show_layer(2)">Thoughts</a> |
<a href="javascript://" onclick="show_layer(3)">Questions?>/a></p>
<div id="poetry">Poetry content</div>
<div id="thoughts">Thoughts content</div>
<div id="questions">Questions content</div>
Then in the <head> section:
Code:
<script type="text/javascript">
function show_layer(lyr)
{
var obj;
obj=document.getElementById("poetry"); //Hide ALL layers
obj.style.display="none";
obj=document.getElementById("thoughts");
obj.style.display="none";
obj=document.getElementById("questions");
obj.style.display="none";
//Grab the correct layer:
if(lyr==1)
{
obj=document.getElementById("poetry");
}
if(lyr==2)
{
obj=document.getElementById("thoughts");
}
if(lyr==3)
{
obj=document.getElementById("questions");
}
obj.style.display="block"; //Make it visible
}
</script>
That should do it! One more thing, though: you said there were 4 tabs but I only see 3.
Bookmarks