View Full Version : Display Divs w/Function problem

11-02-2005, 06:07 PM

I have the following code:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script language="javascript" type="text/javascript">
function switchDiv(div1,div2,div3,div4,div5) {
document.getElementById(div1).style.display = 'block';
document.getElementById(div2).style.display = 'none';
document.getElementById(div3).style.display = 'none';
document.getElementById(div4).style.display = 'none';
document.getElementById(div5).style.display = 'none';


<a href="#" onClick="switchDiv(name1, name2, name3, name4, name5);">Trial 1</a><br>
<a href="#" onClick="switchDiv(name2, name1, name3, name4, name5);">Trial 2</a><br>

<div id="name1">DIV1</div>
<div id="name2">DIV2</div>
<div id="name3">DIV3</div>
<div id="name4">DIV4</div>
<div id="name5">DIV5</div>

I keep getting an object required javascript error. Does anyone know why this is occurring? I'm sure it's something simple, but I'm not sure what it is.

Thanks in advance for any help you can provide me with!

11-02-2005, 06:17 PM
Should be:

<a href="#" onClick="switchDiv('name1', 'name2', 'name3', 'name4', 'name5');">Trial 1</a><br>
<a href="#" onClick="switchDiv('name2', 'name1', 'name3', 'name4', 'name5');">Trial 2</a><br>

11-02-2005, 06:51 PM
Thanks John!

I knew it was something simple I was overlooking. Thanks again!