Welcome to Dream.In.Code
Become an Expert!

Join 149,478 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,612 people online right now. Registration is fast and FREE... Join Now!




Simple Show/Hide Text Button for Forum

 
Reply to this topicStart new topic

Simple Show/Hide Text Button for Forum

Dusty84
16 Apr, 2007 - 09:55 PM
Post #1

New D.I.C Head
*

Joined: 16 Apr, 2007
Posts: 3



Thanked: 1 times
My Contributions
Hi, my name is Dusty! This looks like one of the better sites so far for HTML help so I'm giving you a try. First of all I'll explain what I'm trying to do. I want a simple html code that will show or hide text when a button is clicked. I would use this code in the BBCode manager of my forum to create a tag such as [showhide] that members could use. I have searched all over the web and can't find the simple answer I'm looking for in html! All I find are much more complex Q&A's. I don't want a text box, or anything fancy, just a button to show or hide the text in the post. I imagine, as I'm not an expert, but more of a beginner, that the code would take the form of:
<whatever the show/hide command is>{here's where the text goes}</whatever the show/hide command is>
I hope I explained this well enough for someone to make me look like a genious on the forum, in fact I would gladly share the credit and throw some kudos to anyone with a successful solution!
User is offlineProfile CardPM
+Quote Post

DilutedImage
RE: Simple Show/Hide Text Button For Forum
17 Apr, 2007 - 04:04 PM
Post #2

D.I.C Addict
Group Icon

Joined: 20 Nov, 2006
Posts: 643



Thanked: 6 times
Dream Kudos: 25
My Contributions
QUOTE(Dusty84 @ 16 Apr, 2007 - 10:55 PM) *
This looks like one of the better sites so far for HTML help so I'm giving you a try.

Thank you; we're honored that you've been so kind as to allow us the opportunity to help you.

QUOTE(Dusty84 @ 16 Apr, 2007 - 10:55 PM) *
I would gladly share the credit and throw some kudos to anyone with a successful solution!


Really? You'd share the credit for your great accomplishment of receiving an answer!? You are far too generous ...

. . .

Really though, you're not going to accomplish that with HTML. There is no magic tag that hides/shows the contents when clicked. Enclose the content in span/div/etc.. tag, and then use Javascript to change it's visibility attribute.




And heres' TONS OF SAMPLE CODE

This post has been edited by DilutedImage: 17 Apr, 2007 - 04:04 PM
User is offlineProfile CardPM
+Quote Post

Dusty84
RE: Simple Show/Hide Text Button For Forum
18 Apr, 2007 - 01:50 PM
Post #3

New D.I.C Head
*

Joined: 16 Apr, 2007
Posts: 3



Thanked: 1 times
My Contributions
Thanks very much! I found and used this:

CODE

<body>
<script type="text/javascript">
<!--
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'none')
e.style.display = 'block';
else
e.style.display = 'none';
}
//-->
</script>
<a onclick="toggle_visibility('foo');"><b><u>Click to

view</b></u></a><div id="foo" style=display:none;>{param}</div>
</body>



Despite the sarcasm, which I suppose I deserved, you were quite helpful smile.gif
User is offlineProfile CardPM
+Quote Post

DilutedImage
RE: Simple Show/Hide Text Button For Forum
19 Apr, 2007 - 12:59 AM
Post #4

D.I.C Addict
Group Icon

Joined: 20 Nov, 2006
Posts: 643



Thanked: 6 times
Dream Kudos: 25
My Contributions
I do what I can. biggrin.gif

And yes, I'm a bit sarcastic sometimes, and I just couldn't resist it on this one. .. No worries though, you didn't do anything to deserve it; it was free of charge.
User is offlineProfile CardPM
+Quote Post

YellowJello
RE: Simple Show/Hide Text Button For Forum
21 Nov, 2007 - 02:30 PM
Post #5

New D.I.C Head
*

Joined: 21 Nov, 2007
Posts: 1


My Contributions
I apologize for bumping this thread after it has been dead for so long, but is there any way to make a button like that with HTML, PHP, or even BBcode (those are the only types accepted on those forums)? The forums that I normally post on do have javascript activated but this code still does not work. Any help will be greatly appreciated.

Also, just in case what I'm asking for is slightly different from what Dusty84 wanted, here's the javascript version of what I want:

CODE
<a href="java script:;" id="dw3_list" onclick="ShowDivRemote('dw3_list','hide_dw3_list','Show Lists...','Hide Lists...')">Hide Lists...</a></b><div style="display: block;" id="dw3_lists">
TEXT HERE
</div></div>


As I've already said before, this is not for the website itself, it's for just a post; so I can't set up any custom script or whatever it's called.

This post has been edited by YellowJello: 21 Nov, 2007 - 05:56 PM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 03:43PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month