Here's what I got:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<script language=vbscript>
sub toggle(id)
if document.all(id).style.display = "block" then
document.all(id).style.display = "none"
else

document.all(id).style.display = "block"
end if
end sub
</script>

</HEAD>
<BODY>
<a href="#" onclick="toggle('more')">Click me</a>
<div id=more style="display:none;">this is more text...</div>
<br>
<a href="#" onclick='toggle("more2")'>Click me again</a>
<div id="more2" style="display:None;">More more text!</div>

</BODY>
</HTML>

A pretty simple show/hide to display text and hide it with a click
again. I was wondering if someone knew how to hide the previously
selected item when an item is selected... I need it to work
automatically without having to write a huge "hideAll()" that hides all
the Divs as this page will change a lot (using for an FAQ/News page)
Thanks!

Re: Automatically hide/show text... by JTW

JTW
Thu Sep 14 12:41:27 CDT 2006

Add a variable outside of any function, then store last-passed id
information in it:

<script language=vbscript>
Dim strLastID

sub toggle(id)
if strLastID <> "" Then
document.all(strLastID).style.display="none"
end if

if document.all(id).style.display = "block" then
document.all(id).style.display = "none"
else
document.all(id).style.display = "block"
end if

strLastID = id
end sub
</script>

--
Jase T. Wolfe
Dx21, LLC
http://www.Dx21.com


Zamael wrote:

> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML>
> <HEAD>
> <script language=vbscript>
> sub toggle(id)
> if document.all(id).style.display = "block" then
> document.all(id).style.display = "none"
> else
>
> document.all(id).style.display = "block"
> end if
> end sub
> </script>
>
> </HEAD>
> <BODY>
> <a href="#" onclick="toggle('more')">Click me</a>
> <div id=more style="display:none;">this is more text...</div>
> <br>
> <a href="#" onclick='toggle("more2")'>Click me again</a>
> <div id="more2" style="display:None;">More more text!</div>
>
> </BODY>
> </HTML>