Fulfill a field using javascript | XM Community
Solved

Fulfill a field using javascript


Badge

Hi everybody, I tried to fulfill the field age using the code below:
Qualtrics.SurveyEngine.addOnReady(function()
{
Qualtrics.SurveyEngine.setEmbeddedData("Age", "44")
});
The field is like this:
temp.jpgBut it doesnt work. How can I do that?

icon

Best answer by bstrahin 4 May 2022, 21:44

View original

7 replies

Userlevel 7
Badge +38

See this documentation on setting a default answer. No need for javascript.

https://www.qualtrics.com/support/survey-platform/survey-module/question-options/add-default-choices/#DisplayingPipedTextInDefaultChoices

Badge

Thanks for your answer, Madison.
But I need to use Javascript because my list is very large and I will read it from a CSV file, exactly when the survey is in course.

Userlevel 7
Badge +38

The code you have written is pointing to an embedded data field. Those can only get set in four ways:
1) from a contact list (it sounds like you are trying to not upload your .csv as a contact list. However if you did do that then the solution I gave you will work. If you are uploading the .csv into contacts look here to make sure it is reading into your survey.)
2) info in the survey link
3) built-in Qualtrics fields
4) values set in the survey flow

But maybe you are trying to use a webservice to host your .csv so I would look at this page: https://www.qualtrics.com/support/survey-platform/survey-module/survey-flow/advanced-elements/web-service/

Badge

Thanks, Madison, that helps a lot.

Userlevel 7
Badge +27

MarceloRychter ,
Fill a text entry field with JS like this:
Qualtrics.SurveyEngine.addOnReady(function() {
jQuery("#"+this.questionId+" .InputText").val("44");
});

Badge

Hi Raleig, that works. I could fulfill the filed. Thanks a lot.
Cheers, Marcelo Rychter

Badge

Thanks Betsy and Thomas. Now I know your names 😊

Leave a Reply