/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Swap Text in Div using multiple buttons…

So here is the code I got so far. Which works….

This code is in a seperate js file

[code][COLOR=Black]function toggleBlock(id) {
if (document.getElementById(id).style.display == ‘none’) {
document.getElementById(id).style.display = ‘block’;
} else {
document.getElementById(id).style.display = ‘none’;
}
}[/COLOR][/code]

The rest is in my HTML page…….

[code]<div id=”blankDiv_text” style=”display:none” class=”textmain”> <p>
<text class=”textheader”>HI</text>
<br>
<text class=”textmain”>The links at the right will guide you<br>
through some examples of the work<br>
I have been busy with lately. If you have<br>
any questions please don&rsquo;t hesitate to<br>
contact me at anytime.<br>
Thanks,
<br>
<br>
Corey Shields</text>
</p></div>[/code]

[code]<div id=”ThumbNav” [COLOR=Black]a href=”javascript:void(0)” onClick=”toggleBlock(‘blankDiv_text’);”[/COLOR]><img src=”fernrdige_up.jpg” alt=”” width=”55″ height=”53″</div>[/code]

Everything works just fine as long as there is only one button…..How do I ad a second button that will populate different text and simultaneously make the current text dissapear so it doesn’t stack. I have been looking and can’t find anything that would make sense here. I may be looking in the wrong places….I don’t know.

Any help would be great.

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@KravvitzSep 13.2007 — [url=http://www.dynamicsitesolutions.com/javascript/swapping-displayed-elements/]Swapping Displayed Elements[/url]
Copy linkTweet thisAlerts:
@libellusauthorSep 13.2007 — Not sure I follow that last post......
Copy linkTweet thisAlerts:
@dtm32236Sep 13.2007 — this should be exactly what you're looking for:

http://www.devpapers.com/article/72
Copy linkTweet thisAlerts:
@KravvitzSep 14.2007 — Not sure I follow that last post......[/QUOTE]
It's an example of a script similar to what you want, though it would need to be modified to use images instead of just text for the links to swap which section is visible.
×

Success!

Help @libellus 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 6.1,
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,
)...