Answering a Text Entry Question using JavaScript

nschwitternschwitter Community Member Qubie ✭

Answering a Text Entry Question using JavaScript

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

  • ShashiShashi India Wizard ✭✭✭✭✭
    Accepted Answer

    Hello @nschwitter ,

    Try using the below code:

    jQuery("#"+this.questionId+" .InputText").val("hello");


Sign In to Comment