0

Hi guys,

Im having a problem with some code here.

I have 2 divs and 2 buttons. I want 1 dive to hide and 1 display when i click one button. And when I click the other button the other div displays/hides.

I'm using the below code but it just won't work for me. Any help would be great!

<script type="text/javascript">
				function toggle_view(show,hide){
					var x = document.getElementById(show);
					var y = document.getElementById(hide);
					
					x.style.display = "block";
					y.style.display = "";
				}
			</script>

Here's my div's code:

<div id="carousel_toggle_top">
[contents]
</div>

<div id="carousel_toggle_special">
[contents]
</div>
2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by cloud09
0

I'm assuming "show" and "hide" are variables that are equal to "carousel_toggle_top" and "carousel_toggle_special", respectively? If not, you need to put "carousel_toggle_top" in the x getElement and "carousel_toggle_special" in the y getElement, with the qoutes. And I would use "none" instead of "" for the display style.

0

Oh yes I forgot to add these:

<a href="#" onclick="toggleview('carousel_toggle_top','carousel_toggle_special');return false;">

<a href="#" onclick="toggleview('carousel_toggle_special','carousel_toggle_top');return false;">
0

You have an under score in "toggleview" when the function is defined but no not when you call the function. I going to say the that will solve your problem. ;)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.