Anyone Know The Code For This Function?

by 11 replies
14
Hi All,

I'm wondering if anyone knows the code that works this function.

If you go to this page https://www.lottosend.com/faq you will see a list of questions.

If you click the question, you see the answer popup directly under the question.

If you then click the 'question' again, the answer closes and the question only is visible

Glen
#programming #code #function
  • Glen check this out:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
    <title>Toggle Test</title>
    
    <style type="text/css">
    #ToggleTarget {
    	display: none;
    }
    </style>
    
    <script type="text/javascript">
    function Toggle() {
    	var el = document.getElementById("ToggleTarget");
    	if (el.style.display == "block") {
    		el.style.display = "none";
    	}
    	else {
    		el.style.display = "block";
    	}
    }
    </script>
    </head>
    
    <body>
    
    <p><a href="javascript:Toggle();">Question1...Bla bla bla</a></p>
    
    <div id="ToggleTarget">The anwser to the question is<br />And the bla bla bla.</div>
    
    </body>
    </html>
    If you would like to add another question:

    Code:
    <body>
    
    <p><a href="javascript:Toggle();">Question1...Bla bla bla</a></p>
    
    <div class="ToggleTarget">The anwser to the question is<br />And the bla bla bla.</div>
    
    <p><a href="javascript:Toggle();">Question2...Bla bla bla</a></p>
    
    <div class="ToggleTarget">The anwser to the question is<br />And the bla bla bla.</div>
    </body>
    you can also try this code;

    Code:
    try this in you html page
    
    <p><a onclick="javascript:ShowHide('HiddenDiv')">Show/Hide</a></p>
    <div class="mid" id="HiddenDiv" style="display: none;">This text was hidden</div>
    <script type="text/javascript">// <![CDATA[
    function ShowHide(divId)
    {
    if(document.getElementById(divId).style.display == 'none')
    {
    document.getElementById(divId).style.display='block';
    }
    else
    {
    document.getElementById(divId).style.display = 'none';
    }
    }
    // ]]></script>
    if you are using wordpress there are plugins that do this, look for short code type plugins!

    • [ 1 ] Thanks
    • [1] reply
    • Thanks Joe,

      I appreciate all that effort you went to
      • [1] reply
  • Thanks joe That is looking useful For me too...
    Heyi can i add you in my contacts..??
    • [1] reply
  • Banned
    [DELETED]
    • [2] replies
    • I think you should open your own thread for this questions (as it is not related to the topic).
      • [1] reply
    • Code:
      To create SEO friendly URLs all you need is a little file called .htaccess.
      
      
      Step 1
      Open up your text editor and type the following:
      RewriteEngine On
      RewriteRule ^([^/.]+)/?$ /index.php?page=$1
      
      Save this as .htaccess and upload to your webserver.
      If you type www.yoursite.com/example, the Apache web server will now interpret it as www.yoursite.com/index.php?page=example
      
      
      Step 2
      The SEO friendly URLs should work now, but you also need a PHP script that will include the subpages.
      The following script is set to include all pages from a directory called "inc", but change it to whatever you like.
      
      Note: This should be in your index.php file where the main content appear.
      <?php
      $page = $_GET['page'];
       
      $def = "home";
      $dir = "inc";
      $ext = "php";
       
      if (isset($page)) {
          $page = substr(strtolower(preg_replace('([^a-zA-Z0-9-/])', '', $page)), 0, 20);
          if (file_exists("$dir/$page.$ext") and is_readable("$dir/$page.$ext")) {
              include("$dir/$page.$ext");
          }
          else {
              include("$dir/error404.$ext");
          }
      }
      else {
          include("$dir/$def.$ext");
      }
      ?>
      
      
      Step 3
      Change all internal links and replace them with your new SEO links.
      For example, if you have a link to index.php?page=about, change this to about.
      
      You're finished! Open your website and try to enter the short SEO friendly URL.
      If this helps click thanks at bottom right!
      • [ 1 ] Thanks
  • Just use shortcode plugin or use ccr-colorful-faq plugin from codexcoder
  • I recently started learning jQuery, and it seems perfect for this. Try this (free) course to learn more: Code School - Try jQuery
    • [1] reply

Next Topics on Trending Feed