Disable Next Button until in page task is complete | XM Community
Question

Disable Next Button until in page task is complete

  • 3 November 2019
  • 1 reply
  • 12 views

I have participants doing a task where they must alternatively type 'a' and 'b' a certain number of times. I have everything working appropriately and have a timer that checks to see how long they work on it. What I need is to disable the participant's ability to continue until they hit the prescribed threshold.

Here is what I've been trying to work with. This works fine for the task but not for forcing them to get to the threshold. In this example, the threshold is 500 times.



Qualtrics.SurveyEngine.addOnload(function()
{
$('NextButton') && $('NextButton').hide();
$('PreviousButton') && $('PreviousButton').hide();
choices = [];
count = 0;
timerID = document.getElementsByClassName('Timer FlipClock')[0].id;
allTimes = '';
var that = this;

//Key Codes: A=65, B=66
Event.observe(document, 'keydown', function (e) {

choices.unshift(e.keyCode);
choices = choices.slice(0,2);
if(choices[0] == 65 && choices[1] == 66 && count < 500)
{
var time = $(timerID).getAttribute('time');
allTimes = allTimes + time + ', ';
count++;
$('count').innerHTML = count;

Qualtrics.SurveyEngine.setEmbeddedData('Count',count);
Qualtrics.SurveyEngine.setEmbeddedData('Times',allTimes);
}
});
});

1 reply

Userlevel 7
Badge +27
Add:
```
if(count >= 500) $('NextButton').show();
```
after you set the embedded data fields.

Leave a Reply