How to get answer into embedded data while on the same page | XM Community
Skip to main content
Solved

How to get answer into embedded data while on the same page

  • April 1, 2019
  • 2 replies
  • 107 views

Hi everyone I am trying to store the answers to two numeric questions with a Javascript into an EmbeddedData Field. I would like to do so on the same page as the question. Currently I save the data in an additional hidden question, but what do I have to add to my code so that it works without additional hidden question? Here is my code so far: ! Thanks a lot

Best answer by TomG

Assuming your numeric questions are single text entry questions, add this script to each question (change the embedded variable): ``` Qualtrics.SurveyEngine.addOnPageSubmit(function() { var answer = jQuery("#"+this.questionId+" .InputText").val(); Qualtrics.SurveyEngine.setEmbeddedData("CQ1_participant_answer", answer); }); ```

2 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • Answer
  • April 1, 2019
Assuming your numeric questions are single text entry questions, add this script to each question (change the embedded variable): ``` Qualtrics.SurveyEngine.addOnPageSubmit(function() { var answer = jQuery("#"+this.questionId+" .InputText").val(); Qualtrics.SurveyEngine.setEmbeddedData("CQ1_participant_answer", answer); }); ```

  • Author
  • April 3, 2019
Thanks for your answer! Works perfectly!