How to make a Digg-style FAQ page with JavaScript and jQuery

Register an Account
Reply
 
Thread Tools Display Modes
  #21 (permalink)  
Old 03-04-2010, 01:00 AM
chuckroast's Avatar
Pligg Developer/Coder/Designer
Pligg Version: SVN
Pligg Template: Social Pro Kit
 
Join Date: Jun 2006
Posts: 5,448
The JavaScript in the <head> needs to be placed in between {literal} JavaScript {/literal} tags
Reply With Quote
  #22 (permalink)  
Old 03-04-2010, 01:23 AM
Casual Pligger
 
Join Date: Apr 2009
Posts: 49
Quote:
Originally Posted by chuckroast View Post
The JavaScript in the <head> needs to be placed in between {literal} JavaScript {/literal} tags
Tried this and it still doesnt work. All i get is the same result on the page but the literal tags show as text... and the three question links but not the title nor the drop down text (answers)... http://www.spirr-it.com/page.php?page=faq-test

PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd"
>
<
html>
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<
title>Digg-style FAQ page</title>
{
literal}
<
script type="text/javascript" src="jquery.js"</script>

<script type="text/javascript">
$(document).ready(function() {                                    
    $("a[name^='faq-']").each(function() {
        $(this).click(function() {
            if( $("#" + this.name).is(':hidden') ) {
                $("#" + this.name).fadeIn('slow');
            } else {
                $("#" + this.name).fadeOut('slow');
            }            
            return false;
        });
    });
});
</script>
{/literal}
<style type="text/css">
.faq-answer {
display:none;
}
</style>

</head>

<body>

   <a href="#" name="faq-1">What is Digg like FAQ?</a><br />
   <div class="faq-answer" id="faq-1">It's like this: http://www.digg.com/faq<br /><br /></div>
   
   <a href="#" name="faq-2">Is it easy to make?</a><br />
   <div class="faq-answer" id="faq-2">Yes it's very easy to make!<br /><br /></div>
   
   <a href="#" name="faq-3">Why would I want to do that?</a><br />
   <div class="faq-answer" id="faq-3">And your page will be so much cleaner.<br /><br /></div>
            
</body>
</html> 
Perhaps jquery file was wrong? or placing this sode in the page creator has something to do with it?

thanks alot i appreciate it!

Last edited by spirrsguy; 03-04-2010 at 01:32 AM. Reason: adding info
Reply With Quote
  #23 (permalink)  
Old 04-02-2010, 04:56 PM
New Pligger
 
Join Date: Apr 2010
Posts: 1
Hi, I looked at your page, you have 2 header sections on the page. You have to put the faqs script header section in between the <head> and </head> tags. When you pasted the script you pasted another head section in, that will not work.

Finally, ad the rest of the script in the body section somewhere between the <body> </body> tags.

Hope this helps.
Reply With Quote
  #24 (permalink)  
Old 05-28-2010, 09:14 AM
aahna's Avatar
Casual Pligger
Pligg Version: 1.1.4
Pligg Template: wistie
 
Join Date: May 2010
Location: India
Posts: 64
@mendim: Thank you so much, i will use this script for my site also...
Reply With Quote
  #25 (permalink)  
Old 05-30-2010, 04:02 PM
New Pligger
 
Join Date: Jun 2009
Posts: 27
it's great,but if i add this to my site,there is one problem?
if i open the page,then i can see the question and the answer,the answer is not hide,i should click to the question to hide the answer,how can i fix it,so that i can firstly just see the question
thanks
Reply With Quote
  #26 (permalink)  
Old 09-14-2010, 12:27 AM
New Pligger
 
Join Date: Sep 2010
Posts: 1
Has anyone figured out how to fix this? When I load the page, the answers are not hidden. What do I need to do to fix this?

Thanks,
Donna

Quote:
Originally Posted by mt1988 View Post
it's great,but if i add this to my site,there is one problem?
if i open the page,then i can see the question and the answer,the answer is not hide,i should click to the question to hide the answer,how can i fix it,so that i can firstly just see the question
thanks
Reply With Quote
Reply

Tags
digg, faq, make, style

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Might be time to think about better use of javascript jbowman Questions and Comments 1 07-20-2007 10:19 AM


Pligg Modules and Pligg Templates from Pligg Pro Find support on the Pligg CMS Forum - 24 hours a day! Make a donation to support Pligg CMS development