Skip to content

Instantly share code, notes, and snippets.

@mattbloomfield
Created July 12, 2018 02:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattbloomfield/9bb4ea7c0ada5556db22bdba7138eda1 to your computer and use it in GitHub Desktop.
Save mattbloomfield/9bb4ea7c0ada5556db22bdba7138eda1 to your computer and use it in GitHub Desktop.
var hiddenQuestionId = 'QID8';
Qualtrics.SurveyEngine.addOnload(function () {
this.questionclick = function(event,element) {
if (element.type == 'radio') {
// save the winner as Embedded Data
var el = document.getElementById(element.id);
var parent = el.parentElement;
var img = parent.querySelector('span img');
Qualtrics.SurveyEngine.setEmbeddedData('Winner', img.id);
// select the hidden question
var choiceId = options[img.id];
Qualtrics.SurveyEngine.registry[hiddenQuestionId].setChoiceValue(choiceId, true);
}
}
// this object will need to be built by you. The Key is the Div ID, the Value is the choice value in
// the hidden question associated with that option.
var options = {
Cards: 1,
Facebook: 2,
Disk: 3,
Speedometer: 4,
Chair: 5,
Linux: 6
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment