Link to home
Start Free TrialLog in
Avatar of Shaye Larsen
Shaye Larsen

asked on

Div change script missing something???

I wrote a simple script to change a div's visibility onClick.

I have 3 divs and only one is visible at a time.

By clicking the next or previous buttons it changes the visiblity to show the correct div. I wrote each click to be a function to change the css styles of each to show the correct div and hide the others.

It does not work, please help me to accomplish this functionality please, thank you.

Here is my code:
<script type="text/javascript">
function changePopuptoPane1() {
	document.getElementById('paneOne').style.visiblity='visible';
	document.getElementById('paneTwo').style.visiblity='hidden';
	document.getElementById('paneThree').style.visiblity='hidden';
}
function changePopuptoPane2() {
	document.getElementById('paneOne').style.visiblity='hidden';
	document.getElementById('paneTwo').style.visiblity='visible';
	document.getElementById('paneThree').style.visiblity='hidden';
}
function changePopuptoPane3() {
	document.getElementById('paneOne').style.visiblity='hidden';
	document.getElementById('paneTwo').style.visiblity='hidden';
	document.getElementById('paneThree').style.visiblity='visible';
}
</script>
<style type="text/css">
#paneOne {
	visibility:visible;
}
#paneTwo {
	visibility:hidden;
}
#paneThree {
	visibility:hidden;
}
#paneOne span {
	cursor:pointer;
}
#paneTwo span {
	cursor:pointer;
}
#paneThree span {
	cursor:pointer;
}
</style>
<div class="innerContent">
 
	<div id="paneOne">
		This is Pane 1<br>
		<span onClick="changePopuptoPane2();">Next</span>
	</div>
	<div id="paneTwo">
		This is Pane 2<br>
		<span onClick="changePopuptoPane1();">Previous</span> || <span onClick="changePopuptoPane3();">Next</span>
	</div>
	<div id="paneThree">
		This is Pane 3<br>
		<span onClick="changePopuptoPane2();">Next</span>
	</div>
 
</div>
 
</div>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Phatzer
Phatzer
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Shaye Larsen
Shaye Larsen

ASKER

Thanks, but no go. Nothing happens when I click, not even an error...???
Hmm, OK...

Also try changing
<script type="text/javascript">

To:
<script type="text/javascript" language="javascript">

-AND-

Try changing
onClick="

To:
onclick="
Still nothing...
OK, I wonder if it's because there's as style sheet style set for the panes, have you tried:

<div id="paneTwo" style="display: none;">

and taken the #paneTwo out of the style sheet?
Hmm, I think there is something wrong with the page I'm on... I have it in a lightbox and I'm using it to change the content in the lightbox. I decided to take it to another page off of the lightbox and it works great...

Here is the working one, can't show you the non-working one cause it is no accessible.

http://dalelarsen.com/beta13/test3.php
Yeah works fine in Safari on Leopard.

Do you have some other code on the other page that has an error maybe? That might prevent the javascript from running.
I just tried changing the id names to make sure they weren't conflicting but that didn't fix it...
Okay, I'll check to see if there are errors
There aren't any errors that I could find with firebug. I removed the other scripts on the page. It is just that script alone on the lightbox now and it still doesn't work.

I am using a lightbox plugin called fancybox -- http://fancy.klade.lv/

It loads the content via ajax
Hmm I'm not sure how much more I can help, as I've not had any experience with that plugin.
Okay, I appreciate your help.
Okay, I made a mistake, you have the solution. When I said it was working on one page and not in the lightbox I had not tried display instead of visibility in the popup, the first time I tried it that way I didn't get it to work because of caching. Anyway, I got it working!
Thanks!
Thank you!