I'm setting an Embedded Variable based on a question.... however, I've used default choices to preselect the response and then hidden the question. Does the code above only work when a response is "clicked" - and if so, do I need to change this.questionclick to something else?
Qualtrics.SurveyEngine.addOnload(function ()
{
//jQuery("#"+this.questionId).hide();
this.questionclick = function(event,element)
{
console.log(event,element);
if (element.type == 'radio')
{
var choiceNum = element.id.split('~')[2];
if (choiceNum == 2)
{
Qualtrics.SurveyEngine.setEmbeddedData("EndLoop", choiceNum);
}
}
}
});
Solved
Setting an embedded variable based on a hidden question... javascript mistake?
Best answer by TomG
https://community.qualtrics.com/XMcommunity/discussion/comment/43884#Comment_43884You can do this:
Qualtrics.SurveyEngine.addOnload(function () {
var q = jQuery("#"+this.questionId);
q.hide();
Qualtrics.SurveyEngine.setEmbeddedData("EndLoop",q.find("input:checked").attr("choiceid"));
})
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
