Hello hive-mind, I'm new to this community & have checked existing posts but have not yet found an answer to the following question:
I have a block ion which I'm running a randomized Loop & Merge. I'd like to display the 1st question in the block only once, in the first run of the loop. Display logic does not seem to work on number of loops as I randomize loop order. Any ideas how to tackle this?
My hunch is I'll need some js that tracks the number of loops but I'd be grateful if you could help me with how to set this up!
Any help is much appreciated!
I have a block ion which I'm running a randomized Loop & Merge. I'd like to display the 1st question in the block only once, in the first run of the loop. Display logic does not seem to work on number of loops as I randomize loop order. Any ideas how to tackle this?
My hunch is I'll need some js that tracks the number of loops but I'd be grateful if you could help me with how to set this up!
Any help is much appreciated!
Page 1 / 1
As long as the first question isn't forced response, you can hide it on all loops except the first with JavaScript:
```
Qualtrics.SurveyEngine.addOnload(function() {
if("${lm://CurrentLoopNumber}" != "1") jQuery("#"+this.questionId).hide();
});
```
```
Qualtrics.SurveyEngine.addOnload(function() {
if("${lm://CurrentLoopNumber}" != "1") jQuery("#"+this.questionId).hide();
});
```
Hi Tom,
this is almost solved my problem – I wanted to completely skip the question after the 1st loop (and the following question break), rather than just hiding it. Sorry if I did not make that clear – and many thanks for your prompt response which put me on the right track.
The following JS does the job:
Qualtrics.SurveyEngine.addOnload(function()
{
if("${lm://CurrentLoopNumber}" != "1")jQuery("#"+this.questionId).hide();
if("${lm://CurrentLoopNumber}" != "1")jQuery("#Buttons").hide();
});
Qualtrics.SurveyEngine.addOnReady(function()
{
if("${lm://CurrentLoopNumber}" != "1")jQuery("#Buttons").hide();
if("${lm://CurrentLoopNumber}" != "1")jQuery('#NextButton').click();
});
this is almost solved my problem – I wanted to completely skip the question after the 1st loop (and the following question break), rather than just hiding it. Sorry if I did not make that clear – and many thanks for your prompt response which put me on the right track.
The following JS does the job:
Qualtrics.SurveyEngine.addOnload(function()
{
if("${lm://CurrentLoopNumber}" != "1")jQuery("#"+this.questionId).hide();
if("${lm://CurrentLoopNumber}" != "1")jQuery("#Buttons").hide();
});
Qualtrics.SurveyEngine.addOnReady(function()
{
if("${lm://CurrentLoopNumber}" != "1")jQuery("#Buttons").hide();
if("${lm://CurrentLoopNumber}" != "1")jQuery('#NextButton').click();
});
Thanks, this worked for me, except that there was a brief flicker of the question before it was hidden. I discovered that changing the question motion to 'fade' in look and feel prevented that.
I think the best way is to create two blocks, one with the first question you want to show, and one with the loop and merge. And then combine them in survey flow with a randomiser and a branch. I know this might not work always (for instance, if you are using the loop and merge in the text of the first question, or you want two questions to appear on the same page) but I find usually that is not the problem.
Thanks so much this worked perfectly!
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.