View Full Version : show hide problem!

Jun 25th, 2008, 07:28 PM
I have successfully inputted one function that creates show and hide, but I need that same sort of function to work independantly for other content on the same page.

The way the code is set up now is so that showing one piece of content hides the last.

This is the code I have that works:

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

var currentSpan = 1;
function showMe(n) {
document.getElementById("ex_"+currentSpan).style.display = "none";
document.getElementById("ex_"+n).style.display = "block";
currentSpan = n;

<a href="recompare.html"><img src="http://i95.photobucket.com/albums/l136/surreal5335/RE%20site/listings.png" onmouseover="rollOn(this); showMe(1)" onmouseout="rollOff(this); " id="hotspot" name="hotspot" vspace="1" hspace="0"></a>

<span id="ex_1" style="display:none;">
<!--content here--!>

I was hoping that some minor changes to this code I can reuse it to control other content indepedantly of the first batch currently being controled by this code.
Any suggestions?

Jun 25th, 2008, 07:39 PM
You mean to just toggle any object visible or not?

function toggleMe(obj,stat) {
obj.style.display = stat;

Jun 25th, 2008, 10:02 PM
I like it so far, just two questions. The part about the 'someElementID'
that I imagine I would need to change, would I change that to a generic type like 'n' for instance or would it be something more specific.

I need this code to be able to toggle 10+ pieces of separate content.

And as for the HTML code what would the Id look like? Any other syntax I would need to be aware of?
Thanks a lot