

https://www.qualtrics.com/community/discussion/comment/22621#Comment_22621This was really helpful for me. 😃
I adapted the code slightly to put the cursor in the box automatically and require 'enter' to advance rather than press the next button. I thought it was working perfectly but when I added the next block that also timed out straight away... what am I doing wrong?
I don't know much about JS so any help appreciated. Here's the code:
Qualtrics.SurveyEngine.addOnload(function()
{
function startTimer(duration) {
var timer = duration;
var myTimer = setInterval(function() {
Qualtrics.SurveyEngine.setEmbeddedData('timeRemaining', timer);
if (--timer <= 0) {
clearInterval(myTimer);
timeOver();
}
}, 1000);
}
var timerSeconds = parseInt("${e://Field/timeRemaining}");
startTimer(timerSeconds);
var timeOver = function() {
$('NextButton').click();
}
});
Qualtrics.SurveyEngine.addOnReady(function()
{
$('NextButton').hide();
if($('PreviousButton')) $('PreviousButton').hide();
var inputText = $(this.questionId).down('.InputText');
var evt = inputText.on('keydown', function(e) {
if(e.which == 13) {
evt.stop();
$('NextButton').click();
}
});
inputText.activate();
});
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.