How to force a response in a qestion using JavaScript | XM Community
Skip to main content

Qbie here
Q1 is asking for the age of the respondent.
Q2 is asking how many they are during a trip.
Q3(Matrix table) would be conditioned to display if Q2 is greater than 1, asking to enter the age of each person included in a trip.
Now if the Q2 is equal to 1, Q3 should not be displayed but I would need to push the Q1 value to Q3. Is there a JavaScript that can help achieving this?

I think you meant:

Q1 is asking for the age of the respondent.

Q2 is asking how many they are during a trip.

Q3(Matrix table) would be conditioned to display if Q2 is greater than 1, asking to enter the age of each person included in a trip.

Now if the Q2 is equal to 1, Q3 should not be displayed but I would need to push the Q1 value to Q3. Is there a JavaScript that can help achieving this?

You don't really need JS for this:
  • Q3 should be a text form, not a matrix.

  • Always display Q3

  • Use default choices to pipe the answer of Q1 into the first row of Q3 (i.e., Yourself)

  • Add display logic to the rows of Q3 (2 through n) based on the answer to Q2

Optionally, you can automatically click the Next button if the answer to Q2 is 1.
Qualtrics.SurveyEngine.addOnload(function() {
if("${q://QIDx/ChoiceTextEntryValue}"=="1"}) this.clickNextButton(); //Change QIDx to correct id
});


Leave a Reply