/    Sign up×
Community /Pin to ProfileBookmark

+ and – expanding tree help…

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?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@skriptorJul 23.2003 — 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
Copy linkTweet thisAlerts:
@xataku_nakusuteauthorJul 23.2003 — 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!!
×

Success!

Help @xataku_nakusute spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...