Answering a Text Entry Question using JavaScript | XM Community
Skip to main content
Solved

Answering a Text Entry Question using JavaScript

  • May 15, 2019
  • 3 replies
  • 452 views

I have a text entry question in my qualtrics survey which I want to answer automatically with "hello" using JavaScript. I added the following line to the addOnReady function to achieve this: `jQuery("#"+this.questionId+" .InputText").attr("value", "hello");` This code has worked in March - the text entry field was automatically filled with "hello" and "hello" was also written in the corresponding row when I exported the data. However, this line does not work anymore. The text entry field remains empty and so does the my dataset. When I inspect the text entry in the browser though, I do find that the attribute value has been set to "hello". The following line worked in March and still works today: `jQuery("#"+this.questionId+" .InputText").attr("placeholder", "hello");` What did Qualtrics change that settingthe value-attribute of a text entry field doesn't do anything anymore? What do I need to change?

Best answer by Anonymous

Hello @nschwitter , Try using the below code: `jQuery("#"+this.questionId+" .InputText").val("hello");`

3 replies

  • 0 replies
  • Answer
  • May 15, 2019
Hello @nschwitter , Try using the below code: `jQuery("#"+this.questionId+" .InputText").val("hello");`

  • Author
  • 5 replies
  • May 17, 2019
Hi @Shashi, great, this works, thanks you!

Forum|alt.badge.img+3
  • Level 1 ●
  • 9 replies
  • August 12, 2019
Can you control the timing of when the text appears? For example, have "hello" display after the text entry question has been displayed after 10 or 15 seconds.