How to read and write the embedded field? | XM Community
Skip to main content

I can't manage to make the following script work:

I compressed it to a minimal non-working example:
Question 1 HTML:


Next question:

Qualtrics.SurveyEngine.addOnload(function(){ 
  document.getElementById("cat").innerHTML=${e://Field/cat};
});
It displays:


Try setting the value as below:
var _Cat = "${e://Field/cat}";
document.getElementById("cat").innerHTML= _Cat;


I always get a warning that any script in the question HTML will be stripped away.
Perhaps you need to add it in the JS box.
Also, your Next Question needs to be at least on the next page. Piping Text and Embedded Data requires a page break between being set and being used.


Solved: if you want to read the text field, you should enclose the name in parentheses like that ""${e://Field/cat}". The correct version:
Question 1 HTML:




Next question (after the page break to make updates):



Qualtrics.SurveyEngine.addOnload(function(){ 

 document.getElementById("cat").innerHTML="${e://Field/cat}";

});

It displays: dog


Leave a Reply