The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Spoiler Code for a HTML page

2 posters

Go down

Solved Spoiler Code for a HTML page

Post by Thistle 26/1/2017, 17:22

Hello, I am trying to create a spoiler for my HTML page. I want it to be really simple, just like FAQ page. I've been trying to search and modify the codes myself, but everything I knew about coding is long forgotten Embarassed I want to have multiple of them on one page if it matters. Thanks in advance.


Last edited by Thistle on 28/1/2017, 03:27; edited 1 time in total
Thistle
Thistle
New Member

Posts : 14
Reputation : 2
Language : English

http://www.makemysimsreal.com/

Back to top Go down

Solved Re: Spoiler Code for a HTML page

Post by Guest 26/1/2017, 17:31

Try adding this code @Thistle Smile

Code:
<a id="show_id" onclick="document.getElementById('spoiler_id').style.display=''; document.getElementById('show_id').style.display='none';" class="link">[Show]</a><span id="spoiler_id" style="display: none"><a onclick="document.getElementById('spoiler_id').style.display='none'; document.getElementById('show_id').style.display='';" class="link">[Hide]</a><br>INSERT CONTENT HERE</span>

You can also change where is says [Show] to a different text in that code as well. Very Happy

Cheers,
James
avatar
Guest
Guest


Back to top Go down

Solved Re: Spoiler Code for a HTML page

Post by Thistle 26/1/2017, 19:47

@Mimikyu, thank you! I've tried inserting two, but only one (the first one) works for me :c
Thistle
Thistle
New Member

Posts : 14
Reputation : 2
Language : English

http://www.makemysimsreal.com/

Back to top Go down

Solved Re: Spoiler Code for a HTML page

Post by Guest 26/1/2017, 20:03

Gotcha @Thistle,
I do apologize that only 1 of those begins to work, I will take a look and give you an update as soon as I can get that fixed!

Cheers,
James
avatar
Guest
Guest


Back to top Go down

Solved Re: Spoiler Code for a HTML page

Post by Thistle 26/1/2017, 20:40

Mimikyu wrote:Gotcha @Thistle,
I do apologize that only 1 of those begins to work, I will take a look and give you an update as soon as I can get that fixed!

Cheers,
James
Thank you very much! I really liked that script (http://www.bloggersentral.com/2013/03/content-spoiler-with-simple-css3.html) but I wanted the design to be very simple (just like the one you provided) and have the ability to choose names for spoilers.
Thistle
Thistle
New Member

Posts : 14
Reputation : 2
Language : English

http://www.makemysimsreal.com/

Back to top Go down

Solved Re: Spoiler Code for a HTML page

Post by SLGray 27/1/2017, 00:37

If you are entering more than one spoiler, you will need to give each one a different ID.


Spoiler Code for a HTML page Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51554
Reputation : 3524
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Solved Re: Spoiler Code for a HTML page

Post by Guest 27/1/2017, 00:45

@SLGray, I was told that by somebody else and I cannot figure out how to do that? Can you show me if at all possible?
avatar
Guest
Guest


Back to top Go down

Solved Re: Spoiler Code for a HTML page

Post by SLGray 27/1/2017, 00:46

Is is what the second would look like:
Code:
        <a id="show_id2" onclick="document.getElementById('spoiler_id2').style.display=''; document.getElementById('show_id2').style.display='none';" class="link">[Show]</a><span id="spoiler_id2" style="display: none"><a onclick="document.getElementById('spoiler_id2').style.display='none'; document.getElementById('show_id2').style.display='';" class="link">[Hide]</a><br>INSERT CONTENT HERE</span>


Last edited by SLGray on 27/1/2017, 00:52; edited 1 time in total


Spoiler Code for a HTML page Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51554
Reputation : 3524
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Solved Re: Spoiler Code for a HTML page

Post by Guest 27/1/2017, 00:49

SLGray wrote:id="spoiler_id"
id="spoiler_id2"

@SLGray, Thank you! I figured it out!

@Thistle, Try using the code below and seeing if it works.

Code:
<a id="x"
  onclick="document.getElementById('y').style.display='';
            document.getElementById('x').style.display='none';"
  class="link">
  [ShowBlock1]
</a>
<span id="y" style="display: none">
  <a onclick="document.getElementById('y').style.display='none';
              document.getElementById('x').style.display='';"
    class="link">
  [Hide]
  </a>
<br>
INSERT CONTENT HERE
</span>

<a id="show_id"
  onclick="document.getElementById('spoiler_id').style.display='';
            document.getElementById('show_id').style.display='none';"
  class="link">
  [ShowBlock2]
</a>
<span id="spoiler_id" style="display: none">
  <a onclick="document.getElementById('spoiler_id').style.display='none';
              document.getElementById('show_id').style.display='';"
    class="link">
  [Hide]
  </a>
<br>
INSERT CONTENT HERE
</span>

Cheers,
James
avatar
Guest
Guest


Back to top Go down

Solved Re: Spoiler Code for a HTML page

Post by SLGray 27/1/2017, 00:53

I edited my post.


Spoiler Code for a HTML page Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51554
Reputation : 3524
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Solved Re: Spoiler Code for a HTML page

Post by Thistle 28/1/2017, 03:27

@SLGray @Mimikyu
Hello again, thank you very much for your help. Everything works fine!
Thistle
Thistle
New Member

Posts : 14
Reputation : 2
Language : English

http://www.makemysimsreal.com/

Back to top Go down

Solved Re: Spoiler Code for a HTML page

Post by SLGray 28/1/2017, 16:08

Problem solved & topic archived.
Please read our forum rules: ESF General Rules


Spoiler Code for a HTML page Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51554
Reputation : 3524
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum