Adding static text after a text entry box | XM Community
Skip to main content

I have a two text entry boxes in a text entry type question and need to add static text labels after the boxes. I know how to add static text, but I need the static text labels to be different after each box. Now the same label appears after both boxes. I want to the text after the second box to say Month/Year.
image.png

You can add text elements by using the insertAdjacentText() method.
In your case, the JS would look like:
Qualtrics.SurveyEngine.addOnReady(function(){
let all_inputs = this.getQuestionContainer().querySelectorAll("input");
all_inputs[0].insertAdjacentText("afterend"," % ");
all_inputs[1].insertAdjacentText("afterend"," Month/Year ");
});


Awesome!! Two more things: 1) Can the static text be bolded? 2) For future use, what is the code to add static text before boxes?


For text formatting you'll need to use

insertAdjacentHTML()
method. You can read about the details regarding the position here and how to format HTML text here.


Leave a Reply