Qualtrics: Automatic blinking cursor (focus) does

2019-09-15 13:18发布

This has been an ongoing issue for me with my Qualtrics survey, where I need an automatic blinking cursor to appear in a textbox as soon as the page/question appears. It works flawlessly using Qualtrics' SE survey builder, but it does not work properly on JFE. Qualtrics could not help me with the issue, and would revert my surveys back to SE, but now they will no longer revert it back to SE so I need to solve this issue.

My code is as follows

$("QR~2_QID1").select();

This also works on SE

document.getElementById("QR~QID1").select();

And this:

var input = document.getElementById('myTextInput');

input.select();

When I use the same code with a JFE survey, it appears to work in the preview, where a blinking cursor appears on the mobile side, but I am still able to type and have the text appear on the desktop side. However, when using the actual survey link, no cursor appears, and I am not able to type unless I click the textbox (which I want to avoid).

I believe the issue has something to do with mobile compatibility. The SE survey preview does not include a mobile version, and it might be that the code on the JFE version is defaulting to mobile for some reason (we are excluding mobile users for our research). I wonder if there is a way to turn off mobile compatibility in JFE.

Something else that I noticed, is that when I create a new survey, and include a textbox with the code on the first page, it actually works properly. However, if I put a multiple choice question on the first page with a page break, the textbox no longer has a blinking cursor on the second page.

1条回答
姐就是有狂的资本
2楼-- · 2019-09-15 13:42

This works fine for me in jfe to focus on the first text input in a question:

Qualtrics.SurveyEngine.addOnload(function() {
    $(this.questionId).down('.InputText').focus();
});

EDIT: Deferring execution might help with conflicts either with page transition or other scripts:

Qualtrics.SurveyEngine.addOnload(function() {
    $(this.questionId).down('.InputText').focus().defer();
});
查看更多
登录 后发表回答