Question T973
Visible to All Users

Copy answer from other question

created 6 years ago

Hi Team,
I am trying to understand, whether surveyJs fits all our business cases. For one specific scenario I am unable find any solution.

Problem Statement :

If an user answer any question once, can that answer be used as an answer in another question, say in same survey or in a separate survey.

What I have found in the examples is that, answer of one question can be used as a part of another question or in the options in the answers. I'm referring the following link

https://surveyjs.io/Examples/Library/?id=survey-shareddata&platform=Angular2&theme=default

Business Case:

If an user answer a question in a survey and the same question is a valid question in another related survey, then user should not have to answer those question which is already answer in the previous survey.

If it is possible in SurveyJS, then I want to understand on how to achieve this.

Regards,
Rajesh

Answers approved by surveyjs Support

created 6 years ago

Hello Rajesh,
You may always set the survey question value as:

JavaScript
survey.setValue("yourQuestionName", yourValue);

And you may set the visible property as

JavaScript
survey.getQuestionByName("yourQuestionName").visible = !!yourvalue

Here is more documentation related to this topic: https://surveyjs.io/Documentation/Library/#data

Thank you,
Andrew
SurveyJS Team

    Show previous comments (1)

      It is totally up to you how will you implement it.
      What JSON do you want to get for every survey?
      You have the full control under survey via JavaScript. Here is some explanation: https://surveyjs.io/Documentation/Library/#objects
      You may add a part of Survey A as a new page/pages. You may make these pages or panels invisible based on some condition.
      You may set the data from Survey A as: survey.data = jsonResultFromSurveyA;

      Thank you,
      Andrew
      SurveyJS Team

        Then, is it possible to share some example showing how we can show response of Survey A inside Survey B

        Thanks,
        Rajesh

          Hello Rajesh,
          I am not sure what exactly do you want to do.
          Do you want me to show how to modify the json object, by pages from Survey A into Survey B?
          Or do you want just to set data from Survey A. In this case it is one line of code: survey.data = jsonREsultFromSurveyA; Here is the example: https://surveyjs.io/Examples/Library/?id=survey-data
          The first task, it is a general task by merging two jons and to do be honest it has little to do with the product itself.

          Thank you,
          Andrew
          SurveyJS Team