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*/
});
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());
});
});
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.
