Hello,

I would like to know if you could help me figure out where does the faq comes from?

I do now know how modify the faq any clue how to do it?

http://tutorialzine.com/2010/08/dynamic-faq-jquery-yql-google-docs/

I have downloaded the demo and could not figure out how to change the faq.

Thanks in advance.

Member Avatar for diafol

Did you read the last bit?

To use this script with your own spreadsheet, you only need to edit the csvURL variable in script.js, and replace it with the CSV URL of your spreadsheet. You can obtain this address from Share > Publish as webpage > CSV dropdown. Also, be aware that when you make changes to the spreadsheet, it could take a few minutes for the changes to take effect. You can speed this up by clicking the Republish now button, found in the same overlay window.

Just change your GoogleDoc spreadsheet

How to change GoogleDoc spreadsheet? Where to place the GoogleDoc spreadsheet? Which link do I need to change?

faq.html

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Dynamic FAQ Section w/ jQuery, YQL &amp; Google Docs | Tutorialzine Demo</title>

<link rel="stylesheet" type="text/css" href="styles.css" />

</head>

<body>

<div id="page">

    <div id="headingSection">
        <h1>Frequently Asked Questions</h1>
        <a class="button expand" href="#">Expand</a>
    </div>


    <div id="faqSection">
        <!-- The FAQs are inserted here -->
    </div>  

</div>

<p class="createdBy"><a href="http://tutorialzine.com/2010/08/dynamic-faq-jquery-yql-google-docs/">Read &amp; Download on Tutorialzine &raquo;</a></p>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script src="script.js"></script>
</body>
</html>

script.js

$(document).ready(function(){

    // The published URL of your Google Docs spreadsheet as CSV:
    var csvURL = 'https://spreadsheets.google.com/pub?key='+
                '0Ahe1-YRnPKQ_dEI0STVPX05NVTJuNENhVlhKZklNUlE&hl=en&output=csv';

    // The YQL address:
    var yqlURL =    "http://query.yahooapis.com/v1/public/yql?q="+
                    "select%20*%20from%20csv%20where%20url%3D'"+encodeURIComponent(csvURL)+
                    "'%20and%20columns%3D'question%2Canswer'&format=json&callback=?";

    $.getJSON(yqlURL,function(msg){

        var dl = $('<dl>');

        // Looping through all the entries in the CSV file:
        $.each(msg.query.results.row,function(){

            // Sometimes the entries are surrounded by double quotes. This is why 
            // we strip them first with the replace method:

            var answer = this.answer.replace(/""/g,'"').replace(/^"|"$/g,'');
            var question = this.question.replace(/""/g,'"').replace(/^"|"$/g,'');

            // Formatting the FAQ as a definition list: dt for the question
            // and a dd for the answer.

            dl.append('<dt><span class="icon"></span>'+question+'</dt><dd>'+answer+'</dd>');
        });


        // Appending the definition list:
        $('#faqSection').append(dl);

        $('dt').live('click',function(){
            var dd = $(this).next();

            // If the title is clicked and the dd is not currently animated,
            // start an animation with the slideToggle() method.

            if(!dd.is(':animated')){
                dd.slideToggle();
                $(this).toggleClass('opened');
            }

        });

        $('a.button').click(function(){

            // To expand/collapse all of the FAQs simultaneously,
            // just trigger the click event on the DTs

            if($(this).hasClass('collapse')){
                $('dt.opened').click();
            }
            else $('dt:not(.opened)').click();

            $(this).toggleClass('expand collapse');

            return false;
        });

    });
});
Member Avatar for diafol

Have you got a Google spreadsheet set up already in your Google Drive? Here's an example of a spreadsheet I've published to the web:

spread.PNG

The line in the code:

  var csvURL = 'https://spreadsheets.google.com/pub?key='+
            '0Ahe1-YRnPKQ_dEI0STVPX05NVTJuNENhVlhKZklNUlE&hl=en&output=csv';

Change the value to the link in the image:

 var csvURL = 'https://docs.google.com/spreadsheets/d/1tF4kHBmuT6B5wMJt-20PDtxAdGgYPG2Rh4jLhzYZxF8/pub?gid=0&single=true&output=csv';

That's just from following the documentation. I've never used it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.