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

different default text for a form field question

  • Mar 31, 2022 5:34 PM UTC
  • 4 replies
  • 537 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");

View original

4 replies

Tom_1842
Level 8 ●●●●●●●●
Forum|alt.badge.img+28
  • Level 8 ●●●●●●●●
  • Answer
  • Mar 31, 2022 8:47 PM UTC

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
  • Apr 1, 2022 7:24 AM UTC

Many thanks Tom_1842!!


Forum|alt.badge.img+1
  • Dec 12, 2023 5:36 AM UTC

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 ●●●●●●●●
  • Dec 12, 2023 2:52 PM UTC

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