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

Adding static text after a text entry box

  • February 2, 2021
  • 3 replies
  • 889 views

Forum|alt.badge.img+1

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

Best answer by ahmedA

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.

View original

3 replies

Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • 2028 replies
  • February 2, 2021

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 ");
});


Forum|alt.badge.img+1
  • Author
  • 1 reply
  • February 3, 2021

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?


Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • 2028 replies
  • Answer
  • February 3, 2021

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