Is there a way to skip to the end of a block based on an entered value being > or < an integer? | XM Community
Skip to main content
Question

Is there a way to skip to the end of a block based on an entered value being > or < an integer?

  • April 5, 2022
  • 3 replies
  • 270 views

Forum|alt.badge.img

I believe this is doable through javascript, but would anyone be able to help me figure out how to skip to the end of a block using logic captured earlier in the survey?

For example, a respondent is asked to pick a number, and then if a randomly drawn number is higher than that, I would like Qualtrics to automatically end the trial by skipping to the end of the block (it's an experiment). Any ideas would be beneficial, thanks!

3 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • April 5, 2022

You wouldn't do this in JavaScript. You should use survey flow branch logic. It might look something like:
image.png


Forum|alt.badge.img
  • Author
  • April 5, 2022

Unfortunately, I need to be able to implement this skipping mechanism on a question-by-question basis. Each question is a new randomly generated number, and it seems this would not allow me that granularity.


Rudi
QPN Level 3 ●●●
Forum|alt.badge.img+16
  • QPN Level 3 ●●●
  • April 6, 2022

maybe you could set a display logic on each question in your block

  1. create embedded data fields

  2. randomNumber and showQuestions

image.pngquestion setup
image.pngadd to the text entry question the below javaScript

Qualtrics.SurveyEngine.addOnPageSubmit(function()
{
let randomNumber = "${e://Field/randomNumber}"
let enteredNumber = document.getElementById('QR~'+this.questionId).value
let showQuestion 

if(Number(randomNumber) > Number(enteredNumber)){

showQuestion = 1
}else if(Number(randomNumber) < Number(enteredNumber)){
 showQuestion = 0
}

Qualtrics.SurveyEngine.setEmbeddedData("showQuestions",showQuestion);
});

add the display logic to all questions in your block

hope this is what you are going for

Best regards

Rudi