Support Forums

Full Version: Spoilers?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm learning the basics of HTML and PHP and I was wondering if there is a way to make spoilers work in HTML or PHP. I looked it up, and everything that people said to do wouldn't work for me.
Do you want spoilers for a forum or a website?

Basically it's a hidden div for the xhtml and the php would probably be a preg_replace.
(04-27-2010, 10:32 PM)Omniscient Wrote: [ -> ]Do you want spoilers for a forum or a website?

Basically it's a hidden div for the xhtml and the php would probably be a preg_replace.

I want to use spoilers on a website. So the div is hidden from the source then?
I made one in my site. It's using a div thing. An easy way to find the source for one is add a spoiler to your post, then get the source code from that page, and Ctrl+F Spoiler or the contents of your spoiler. (That's how I did it)
(04-27-2010, 11:36 PM)daneasaur Wrote: [ -> ]I made one in my site. It's using a div thing. An easy way to find the source for one is add a spoiler to your post, then get the source code from that page, and Ctrl+F Spoiler or the contents of your spoiler. (That's how I did it)

Thank you Daneasaur. By the way, were you able to use multiple spoilers? I heard that if it's done you can only use one per page, or something like that.
You can use two, I remember I had to google to figure out how, but it wasn't anything hard. Something simple like not using two in the same dev or something.
Look at this:

In the tag <head> and </head>
Code:
<script type="text/javascript">
function Suite(lien){
    
    var objet = document.getElementById('popup'); // In the ' you put the name of the div you want to hide
    
    if(objet.style.display == "none" || !objet.style.display){
        
        objet.innerHTML = "Text to show";
        objet.style.display = "block";
        objet.style.overflow = "hidden";
        lien.innerHTML = "-";
      
        var hFinal      =     200;  //Final Height
        var hActuel     =     0;         //Initial Height
      
        var timer;
        var fct =        function ()
        {
                hActuel  +=       20;     //Height
                
                objet.style.height     =     hActuel      +     'px';
                
                if( hActuel > hFinal)
                {
                        clearInterval(timer);   //We stop the timer
                        objet.style.overflow    =   'inherit';
                }
        };
        fct();

        
        timer = setInterval(fct,40);    //Every 40 ms
        
    }else if(objet.style.display == "block"){
        
        var hFinal      =     0;  //Final Height
        var hActuel     =     200;         //Initial Height
      
        var timer;
        var fct =        function ()
        {
                hActuel  -=   20;     //Height
                
                objet.style.height     =     hActuel      +     'px';
                
                if( hActuel < hFinal)
                {
                        clearInterval(timer);   //We stop the timer
                        objet.style.overflow    =   'inherit';
                        objet.style.display     =   "none";
                }
        };
        fct();

        
        timer = setInterval(fct,40);    //Every 40 ms
        

        lien.innerHTML = "+";
        
    }
}
</script>

In the tag <body> and </body>:
Code:
[<a href="javascript:;" onclick="Suite(this)">+</a>]

<div id="popup" style="display: none; border: #000000 1px solid; width: 300px;">

</div>

<br /><br />Here :)

I hope it help you
Thanks for your help guys. I finally got it. Smile