Autofocus a text box field | XM Community
Skip to main content

I thought I would share this since I needed it for a survey. My use-case involves scanning barcodes to verify the values meet certain conditions. I want my users to simply load the survey and begin scanning barcodes and not have to manually select the text field with their cursor each time they need to scan a barcode.

So if you have a text field that you want the user cursor auto focused on when the question loads (to save the user from needing to manually select it to begin typing or entering text), you can use the following javascript within your question. (Side note: if the text field currently has a value entered in it when the question loads then the cursor might NOT be visible, but the text field should have focus if javascript is enabled.)

Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
var qid = this.questionId;
var inputText = jQuery("input[id='QR~"+qid+"']");
inputText.trigger('focus');
});

 

@w.patrick.gale Hello!
How are you able to have users scan barcodes? I am in desperate need of this!!
Thank you!


@molnare You just need a barcode scanner (either app for phone or something like a USB scanner).


@w.patrick.gale 
I have that, I haven’t been able to figure out how to scan a barcode and have the barcode value store in Qualtrics.
 

Here’s the use-case, in case that’s helpful.
A program participant enrolls in a coupon program via a Qualtrics form on an iPad
At the end of the form, the participant is directed to give the iPad to the person who is enrolling the participant.
The enrolling person then needs to enter the alpha-numeric code from the coupon booklet that they are distributing. 
This connects a participant with their coupon and allows us to track coupon use at the participant level.

There have been a lot of data integrity issues with the last step. Since the coupons also have a barcode, I would love to have the enrolling person be able to take a picture of the barcode instead of type in the code.

I tried File Upload to be access the camera, but so far I’ve only been able to have it take a picture of the barcode - not read it.

 

Thank you so much for taking the time to respond!


@molnare You will not be able to do that strictly through the survey. You will need an external barcode scanner connected to the iPad using the process you are working with.

If I were you would scrap the barcode scanning idea within the survey and instead focus on creating a unique URL for each participant either via a QR code with the coupon code included in the survey URL or some other URL that is clicked on within the iPad. Then within the survey you will read the coupon code from the query string and attach to the participant response.


Leave a Reply