Display logic within question possible? | XM Community
Skip to main content

I have a Loop Merge set of questions.  However if there is only 1 loop necessary, I want the language to omit the Loop and Merge Field1 and Field2 without having to create 2 sets of questions.

 

What is the age of the ${lm://Field/1}${lm://Field/2} child?

If only 1 child: What is the age of the child?

 

If more than 1 child: What is the age of the 1st child?…. What is the age of the 2nd child?

Hi @Rhaven Nelson , you could try this :

Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/

var totalLoops ="${lm://TotalLoops}";
if (totalLoops == 1) {
jQuery("#"+this.questionId+" .QuestionText").html("What is the age of the child?");
}

});

 


@Rhaven Nelson,

You can do it with a bit of JS. Assuming you captured the number of children in a previous question, you can do the following.

Question html:

What is the age of the <span class="ordinal">${lm://Field/1}${lm://Field/2}</span> child?

JS:

Qualtrics.SurveyEngine.addOnload(function() {
if("{pipe number of children here}"=="1") {
jQuery("#"+this.questionId+" .ordinal").hide();
}
});

 


Thank you!!


Leave a Reply