different default text for a form field question | XM Community
Skip to main content
Solved

different default text for a form field question

  • March 31, 2022
  • 4 replies
  • 473 views

Forum|alt.badge.img+1

Can anyone please help me with adding default text that can be different for each of the following fields, this is a form field question. I have the same issue with multiple choice question where I add a text entry box to each option and I want to add a different default text in each box.
Thank you
Screenshot 2022-03-31 at 16.25.16.png

Best answer by Tom_1842

Hi there, try adding the below to your Form Field question as Javascript in the OnLoad section. Change the "Placeholder#" text as needed.
jQuery("#"+this.questionId+" input[type=text]").eq(0).attr("placeholder", "Placeholder1");

jQuery("#"+this.questionId+" input[type=text]").eq(1).attr("placeholder", "Placeholder2");

jQuery("#"+this.questionId+" input[type=text]").eq(2).attr("placeholder", "Placeholder3");

4 replies

Tom_1842
Level 8 ●●●●●●●●
Forum|alt.badge.img+28
  • Level 8 ●●●●●●●●
  • 909 replies
  • Answer
  • March 31, 2022

Hi there, try adding the below to your Form Field question as Javascript in the OnLoad section. Change the "Placeholder#" text as needed.
jQuery("#"+this.questionId+" input[type=text]").eq(0).attr("placeholder", "Placeholder1");

jQuery("#"+this.questionId+" input[type=text]").eq(1).attr("placeholder", "Placeholder2");

jQuery("#"+this.questionId+" input[type=text]").eq(2).attr("placeholder", "Placeholder3");


Forum|alt.badge.img+1
  • Author
  • 12 replies
  • April 1, 2022

Many thanks Tom_1842!!


Forum|alt.badge.img+1
  • 4 replies
  • December 12, 2023

HI @Tom_1842 

 

Just tried it but it is still asking to put value on it

 


Tom_1842
Level 8 ●●●●●●●●
Forum|alt.badge.img+28
  • Level 8 ●●●●●●●●
  • 909 replies
  • December 12, 2023

Hi @lerasga, the Placeholder attribute is different from the Value attribute. Where the Placeholder attribute specifies a short hint that describes the expected value of an input field, the Value attribute is used to set the actual value to input elements. So, those Form Fields are still unanswered according to Qualtrics. You could use the below instead to update the Values of the Form Fields, or use Default Choices which will do the same thing.

jQuery("#"+this.questionId+" input[type=text]").eq(0).attr("value", "Value1");
jQuery("#"+this.questionId+" input[type=text]").eq(1).attr("value", "Value2");
jQuery("#"+this.questionId+" input[type=text]").eq(2).attr("value", "Value3");