Answering a Text Entry Question using JavaScript | XM Community
Solved

Answering a Text Entry Question using JavaScript

  • 16 May 2019
  • 3 replies
  • 293 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?
icon

Best answer by Anonymous 16 May 2019, 01:45

View original

3 replies

Hello @nschwitter ,

Try using the below code:

`jQuery("#"+this.questionId+" .InputText").val("hello");`
Hi @Shashi,
great, this works, thanks you!
Badge +3
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