Solved
Setting embedded data using javascript
I've read through every post on this topic but I still can't seem to get this to work. I want to capture an answer from a matrix dropdown list into embedded data. Then I want to show that response in a matrix text box in a later block. However, we're also giving the respondent the option to go back and change their answer.
I've tried this without JS by setting the answer as embedded in the survey flow, then piping it in the other block. But when the respondent goes back to change their answer, the piped answer doesn't update in the other block.
So I'm trying to use JS to capture the answer, but the answer is not capturing. I have this code in question JS:
Qualtrics.SurveyEngine.setEmbeddedData('User_answer', currentResponse);
Qualtrics.SurveyEngine.getEmbeddedData('User_answer');
Then I added 'User_answer' as an embedded data element at the very top of my survey flow.
What am I missing?
Best answer by Anonymous
Hello @Julie_130 ,
Step 1: Create Embedded data in the survey flow before matrix drop down list question.
The number of embedded data depends on the number of statements you have in matrix drop down list question. For eg if you have 3 statement then make Answer1, Answer2, Answer3 embedded data.
Step 2: Paste the following code in the `js(OnReady)` of the matrix drop down list question
jQuery("select").on('click', function(){
Qualtrics.SurveyEngine.setEmbeddedData('Answer1',jQuery("select:eq(0) :selected").text());
Qualtrics.SurveyEngine.setEmbeddedData('Answer2',jQuery("select:eq(1) :selected").text());
Qualtrics.SurveyEngine.setEmbeddedData('Answer3',jQuery("select:eq(2) :selected").text());
});
Step 3:Pipe in the embedded data(Answer1, Answer2, Answer3) wherever required, in your case it will be in a matrix text box and you will do this while designing the question.
View originalLeave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.