Hello everyone im currently working on a survey where i want to put text entry in the middle of the sentences.
Therefore my questions would look like this
'' I am [Text Entry] years old '' or '' Im working in a company named [Text Entry] since [Text entry]''
Is it possible ?
I saw a JS Script for that here https://psrc.princeton.edu/sites/psrc/files/html_tips_tricks.pdf (i adapted it to my questions) but it didnt worked.
Any tips on how doing it ?
Thanks a lot
The solutions will be different for one input and more than one. This is due to the restrictions imposed by Qualtrics in displaying text entry questions, so below is the general solution.
Use a descriptive text type question and edit its HTML to create the required fields. A text entry box is part of the input family of HTML5. Read about the various kinds here as you'll need it to understand and customize the code to your needs. You can also add an id to each element to extract its value.
So finally you should have something like this:
I'm working in a company named since
Once you've defined your input. You can use JS to store the value in embedded data variables with this code:
Qualtrics.SurveyEngine.addOnReady(function () {
let inputs = this.questionContainer.querySelectorAll("input");
document.querySelector("#NextButton").onclick = function () {
inputs.forEach((item) => {
Qualtrics.SurveyEngine.setEmbeddedData(item.id, item.value);
});
};
});
Based on the HTML above, you will have two embedded variables
companyand
dojwhich will have the values corresponding to the ids.
For sizing and other restrictions, refer to the pages above or use google to find the appropriate properties.
Thanks a lot, it's working like charm :)
Here are some tips to add text entry in the middle of a sentence
Input Type "Text"
An input element with the type property “text” specifies a text input field. This field has a text box where users can edit a line of plain text. Text controls collect small text strings like titles, names, tags, etc.
//defines a single-line text input field
Example of a Text Input Field:
Refer to this article and learn various inputs types
Hi there, thanks for sharing this! It's exactly what I was looking for. I've never used embedded data in this way so figured I'd share how to add it.
In the survey flow, you need to:
- Add Below -> Embedded Data
- Name the field after the ID(s) in your HTML accordingly
- Make sure to hit Apply within the survey flow screen
- Publish your survey or re-publish to double check the values that are being recorded are correct
For a much more robust and flexible fill-in-the-blank solution see this.
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.