Question T1967
Visible to All Users

Output survey.data survey results to HTML

created 6 years ago (modified 6 years ago)

I'd like to be able to output the survey results into HTML and not stringified JSON. Ideally so I can display it in a nice way on the page (like a summary of the results) or even use it to generate charts/graphs. I've tried a few things to grab the result.data, but each time it doesn't output anything unless I wrap survey.data in JSON.stringify().

Example of what I'd like to see instead of the JSON.stringified result data:

HTML
<h1>Results:</h1> <p><strong>Question 1:</strong></p> <p>Value of question 1</p>

Basically I'm not going to store results into a database and want to display it in the DOM in some way. I even tried to use Handlebars/Mustache to parse the JSON and display in HTML, but I can't get it to work.

Any direction you could provide would be appreciated.

Show previous comments (10)

    Hello,
    You did not stringify the JSON object to show it as a text. Here is the forked version.

    Thank you,
    Andrew
    SurveyJS Team

      Thank you Andrew. I guess I have a different understanding of the word "plain" and text. What I'm seeing is still being output as JSON. I'd like to just get regular, plain text. It seems there's nothing built-in to SurveyJS to do this?

        survey.getPlainData() - returns results for matrix dynamic, panel dynamic and multiple text in flat (non tree) form. It includes question.title (column/item title) and display value as well.

        You may always convert json into text by using JSON.stringify(myJson) function.

        Thank you,
        Andrew
        SurveyJS Team