Answering a Text Entry Question using JavaScript | XM Community
Skip to main content
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?
Hello @nschwitter ,



Try using the below code:



`jQuery("#"+this.questionId+" .InputText").val("hello");`
Hi @Shashi,

great, this works, thanks you!
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.

Leave a Reply