Click to See Complete Forum and Search --> : HTML Help Show/Hide Div


coded-red
09-05-2008, 10:23 PM
So,here's what I want to do:
I have a page that will have 2 links at the top that control 2 divs. I want the divs to be hidden on load and when you click on a link it shows one of the divs and hides the other div. Below is a sample of the code I am using. I'm not a pro at all with this so any examples are appreciated.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script language="javascript">
function toggleDiv(divid){
if(document.getElementById(divid).style.display == 'none'){
document.getElementById(divid).style.display = 'block';
}else{
document.getElementById(divid).style.display = 'none';
}
}
</script>

</head>

<body>

<p><a href="javascript:;" onMouseDown="toggleDiv('div1');">Link 1</a></p>
<p><a href="javascript:;" onMouseDown="toggleDiv('div2');">Link 2</a>
</p>
<div id="div1">Text for Link 1</div>

<br>
<div id="div2">
<p>Text for Link 2</p>
</div>
</body>
</html>

Hope i'm in the right forum :)

Oh, and all that above was me working from other forums and copying/pasting code. Hope it's not too much of a mess.

coded-red
09-08-2008, 12:42 PM
Ignore this, I changed up the code... and just realized I posted this in the wrong section :) sorry