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

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

  • March 4, 2021
  • 3 replies
  • 132 views

Forum|alt.badge.img

I have a simple multiple-choice question that has "yes" and "no" as answer options. Is it possible to get it into my embedded data on the same page as the question?

I would like my embedded data to read "yes" and "no" like the answer options.

Similar to this question (this question is the text entry version):
https://www.qualtrics.com/community/discussion/4176/how-to-get-answer-into-embedded-data-while-on-the-same-page

which was answered by
Qualtrics.SurveyEngine.addOnPageSubmit(function() {
var answer = jQuery("#"+this.questionId+" .InputText").val();
Qualtrics.SurveyEngine.setEmbeddedData("CQ1_participant_answer", answer);
});
basically I just need to know what to replace the

.InputText
with. Thank you!

Best answer by ahmedA

var answer = this.questionContainer.querySelector(".q-checked").nextElementSibling.innerText;

3 replies

Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • Answer
  • March 4, 2021

var answer = this.questionContainer.querySelector(".q-checked").nextElementSibling.innerText;


Forum|alt.badge.img

Thanks this completely answers my question and I will accept your answer. Would you let me know how you figured this out so that I can do this by myself next time?


Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • March 5, 2021

You can start here and here.