I have loop and merge block with one Text Entry question. The question should display as field 1: text box, as shown in the picture below. I used javascript to place the field 1 text (in this case, swim : ) just before the text box.
I also added some javascript so that once someone types their answer, they can press ENTER to continue (the next button has been removed). I would like the cursor to automatically appear in the text box such that individuals can start typing without having to use the mouse to navigate to the text box. I found a solution that almost works. It works on every loop in "Preview" mode but only on the first time through the loop in the actual published survey. It also works in the full survey mode on every loop as long as I refresh each page or if I hit tab first on every page.
Why might this be happening? How can I allow individuals to immediately type their answer into each text box without having to use the mouse? Thank you in advance for your help. Here is the code I used in the Javascript for the question:
Qualtrics.SurveyEngine.addOnload(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();
var inputs = $(this.getQuestionContainer()).select('input)type="text"]');
for (var i = 0; i < inputs.length; i++) {
var input = inputsai];
$(input).insert({before: '${lm://Field/1} : '});
}
});