Click to See Complete Forum and Search --> : + and - expanding tree help...


xataku_nakusute
07-23-2003, 01:44 AM
im trying to make something where theres a + "some text"
and when you click on it, the + becomes a minus(but the text stays) and a block of more text and stuff appears

then, when the - is clicked, i want it to restore its former propertis(aka "+ 'some text'")

this would simulate an expanding tree element-like thingy

i tried to use a series of javascripts such as

<script type="text/javascript">
function show(txt) {
obj = document.getElementById(txt);
obj.style.display == "block" ? obj.style.display = "none" : obj.style.display = "block"; // {
}
</script>

and using different combinations of em together onClick, but it just aint workin...

any suggestions?

skriptor
07-23-2003, 03:43 AM
Hi,
try something like this:

<html><head>
<script type="text/javascript" language="JavaScript">
function show(txt) {
obj = document.getElementById(txt);
aTag = document.getElementById(txt + "a");
if ( obj.style.display == "block" ) {
obj.style.display = "none"
aTag.firstChild.nodeValue = "+";
} else {
obj.style.display = "block"; // {
aTag.firstChild.nodeValue = "-";
}
}
</script></head><body>
hello <a id="helloa" href="javascript:show('hello')">-</a>
<div id="hello" style="display:block">world</div>
</body></html>

Good luck, skriptor

xataku_nakusute
07-23-2003, 05:35 AM
thanx dude! worx perfectly!

btw, skriptor, would you like to join my web forum?

http://xio.proboards22.com/

ask me if ya wanna become a mod/gmod there

THANX AGAIN!!