I am trying to load a list of labels (separated by commas), randomly remove one, display it, and store the remaining labels as embedded data. The following code manages to do all but the last one. That is console.log(backup_label) outputs the list of remaining labels but it is not saved to the embedded data. Does anyone know why the setEmbeddedData method does not seem to work from within questionclick function or is there maybe a way of passing the backup_label variable somewhere else in order to then use the setEmbeddedData method?
Qualtrics.SurveyEngine.addOnload(function()
{
this.questionclick = function(event,element){
if (element.type == 'checkbox') {
var backup_label = "${e://Field/backup_label}";
backup_label = backup_label.split(",");
i = Math.floor(Math.random() * backup_label.length);
var current_label = backup_label.splice(i, 1); //remove random label
backup_label = backup_label.join(); //join remaining labels
document.querySelector("#label").innerText = current_label; //display label
console.log(backup_label);
Qualtrics.SurveyEngine.setEmbeddedData('backup_label',backup_label);
}
}
});
Question
Why does setEmbeddedData not work?
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
