Hi - I'm new to Qualtrics and JavaScript. I can't get the simplest code to set embedded data to work. I've seen other posts on the topic, but I'm still stuck.
I created a field called "Field1"
I created a question with JavaScript to set it's value
The next question uses Field1
And when I preview the survey, nothing shows.
I think I'm doing all the steps in the other examples, but it's not working.
Thanks for any help!!
mhv Please make sure, you are using the same embedded data inside javascript. Embedded data defined in survey flow is "Field1" and the one which is used inside Javascript is "Field".
https://community.qualtrics.com/XMcommunity/discussion/comment/48130#Comment_48130Hi resh_kr - Thank you. I did make that change and it still doesn't work (I had made a mistake when creating the post). Any more thoughts? It still doesn't work when the names are all Field1.
mhv Try this:
Qualtrics.SurveyEngine.addOnPageSubmit(function(type)
{
if(type == "next")
{
Qualtrics.SurveyEngine.setEmbeddedData("Field1", "Test");
}
});
Hi resh_kr - Thanks again. It still doesn't work. I have that code in the first question, and then in the second question when it tries to display Field1 it still shows nothing. I feel like there is something basic going wrong but I don't know what it is. Is there some configuration or something needed?
Ha! I got it to work. I added a page break between the two questions. That must cause it to load and therefore run the code. Sigh.
Thank you!
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.