Hello!
I am trying to create a highlight question with the text coming from the displayed choice of a previous question. I have learned a lot from the community and figured out the basic logic is to first make a placeholder in the highlight text and then replace it with the piped text. But I have no previous experience with javascript and just tried to make some code that could be totally wrong (not working).
I was wondering if there is anyone who could help me with it. Thanks a lot!
Qualtrics.SurveyEngine.addOnload(function()
{
var text1 = "${q://QID2/ChoiceGroup/DisplayedChoices}";
var elems = document.getElementsByClassName('HLTextWord');
jQuery("#"+this.questionId+" span.HLTextWord").replace( elems,text1);
/*Place your JavaScript here to run when the page loads*/
});
Solved
Highlight question with the text from previous piped text
Best answer by ChiragK
Based on your code in the question, here's the updated version of same code that might work for you
Qualtrics.SurveyEngine.addOnReady(function () {
var $this = jQuery(this.questionContainer);
var choices = "${q://QID2/ChoiceGroup/DisplayedChoices}".split(",");
jQuery(".QuestionBody .HLTextWords .HLTextWord", $this).each(function (i) {
jQuery(this).text(choices[i].trim());
});
});
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.