Loop & Merge until a specific option is selected | XM Community

Loop & Merge until a specific option is selected

  • 21 February 2023
  • 1 reply
  • 129 views

Badge +1

(Think of my question like a listing of hotels on say, Expedia).
I have a question which lists 10 options. The user can choose any option which leads him to a 'detailed' page for that option. From that detailed page, he has two choices - 'Back to list' and 'select as final' . If the user chooses 'Back to list' he should be taken to the original list of 10 options. If he chooses 'Select as final', he should be taken to the next block of questions.
The way I was thinking of implementing this was to loop & merge the block for 10 times (I do not see any user repeating it for more than 10 times), and if the 'select as final' option is chosen, using skip logic to go to 'End of the block'. The problem is that skipping to 'End of the block' does not break the loop, and it still loops all 10 times before the next block is displayed. Is there any way of breaking the loop if a particular option is selected?
I do not know custom coding so any answer which does not resort to a custom code would be preferred, if possible. Thanks in advance!


1 reply

Userlevel 7
Badge +27

You can use JavaScript to set an embedded data flag when 'Select as final' is selected. Use that embedded data flag in display logic on all the questions in the loop.
Let's say 'Select as final' is the last choice in a MC question. Then the JS would be:
Qualtrics.SurveyEngine.addOnPageSubmit(function() {
if(jQuery("#"+this.questionId+" [type=radio]").last().is(":checked")) Qualtrics.SurveyEngine.setEmbeddedData("skipToEnd","1"); });
});
Display logic on each question in the loop would be:
If Embedded Data skipToEnd Is Not Equal To 1

Leave a Reply