In the Survey flow, I've set up Pre1, Pre2, Pre3, Pre4 as embedded data fields.
I created a Pick, Group, & Rank item where the participant can drag and drop 7 choices into 4 different groups (Pre1, Pre2, Pre3, Pre4).
All I want to do is save the groups to the embedded data fields so I can use them later.
I tried to write some code but It doesn't work. Any help would be appreciated.
Hi,
what do you mean by using the groups later? If you don't want to use the groups in your survey the solution is easy Qualtrics would do this for you in the data :
if you need the items with their respective groups in the survey it is getting somewhat more complicated as you have to something like the below:
Qualtrics.SurveyEngine.addOnPageSubmit(function()
{
let pre1 = document.getElementById('QID1group0') //adopt QID1group0 according to your survey
let pre2 = document.getElementById('QID1group1') //adopt QID1group1 according to your survey
let pre3 = document.getElementById('QID1group2')//adopt QID1group2 according to your survey
let pre4 = document.getElementById('QID1group3')//adopt QID1group3 according to your survey
let pre1Content = pre1.getElementsByTagName('li')
let pre1ContentLabels = new Array
let pre2Content = pre2.getElementsByTagName('li')
let pre2ContentLabels = new Array
let pre3Content = pre3.getElementsByTagName('li')
let pre3ContentLabels = new Array
let pre4Content = pre4.getElementsByTagName('li')
let pre4ContentLabels = new Array
//finding and storing the labels of the items
if(pre1Content.length > 0){
for(let i=0;i
}
}
if(pre2Content.length > 0){
for(let i=0;i
}
}
if(pre3Content.length > 0){
for(let i=0;i
}
}
if(pre4Content.length > 0){
for(let i=0;i
}
}
console.log(pre1ContentLabels)
//writing the items into your embedded data as comma separated strings
Qualtrics.SurveyEngine.setEmbeddedData("pre1", pre1ContentLabels.join(','));
Qualtrics.SurveyEngine.setEmbeddedData("pre2", pre2ContentLabels.join(','));
Qualtrics.SurveyEngine.setEmbeddedData("pre3", pre3ContentLabels.join(','));
Qualtrics.SurveyEngine.setEmbeddedData("pre4", pre4ContentLabels.join(','));
});
Hope this helps to find your solution
Best regards
Rudi
Thanks! It works now!
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.