In the Survey flow, I've set up Group1a, Group1b, & Group1c as embedded data fields
I created a Pick, Group, & Rank item where the participant is to drag and drop their top three (of six) choices into a single group.
All I want to do is save the selected choices to the embedded data fields so I can use them later.
I'm really new to Javascript. I wrote the code below, which literally doesn't seem to do anything. I made another item which is multiple choice where I pipe into the options text the embedded data fields. When running through a preview, all three of the multiple choice option texts are blank. Any help would be appreciated.
I wrote the following code into the Pick, Group, & Rank item
Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/
let choicesall = this.getSelectedChoices();
let choicesarray = choicesall.split(",");
Qualtrics.SurveyEngine.setEmbeddedData('Group1a', choicesarray[0]);
Qualtrics.SurveyEngine.setEmbeddedData('Group1b', choicesarray[1]);
Qualtrics.SurveyEngine.setEmbeddedData('Group1c', choicesarray[2]);
});
Saving Pick, Group, & Rank responses to Embedded Data with Javascript
Best answer by ChiragK
Hello, Try following code, hope that helps.
Qualtrics.SurveyEngine.addOnReady(function () {
var $this = jQuery(this.questionContainer);
var $groupUl;
jQuery(".QuestionBody .groupsContainerTd .Group", $this).each(function (i) {
$groupUl = jQuery(this).find("ul.ui-sortable");
$groupUl.sortable({
update: function (event, ui) {
Qualtrics.SurveyEngine.setEmbeddedData('Group1a', "");
Qualtrics.SurveyEngine.setEmbeddedData('Group1b', "");
Qualtrics.SurveyEngine.setEmbeddedData('Group1c', "");
jQuery("li", $groupUl).each(function (i) {
if (i === 0) {
Qualtrics.SurveyEngine.setEmbeddedData('Group1a', jQuery(this).find("label[for]").text().trim());
} else if (i === 1) {
Qualtrics.SurveyEngine.setEmbeddedData('Group1b', jQuery(this).find("label[for]").text().trim());
} else {
Qualtrics.SurveyEngine.setEmbeddedData('Group1c', jQuery(this).find("label[for]").text().trim());
}
});
}
});
});
});
Sign up
Already have an account? Login
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login to the Community
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
