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

How to read and write the embedded field?

  • March 3, 2021
  • 4 replies
  • 60 views

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

Best answer by SunDevil

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

4 replies

  • Author
  • March 3, 2021

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:


PraDeepKotian_XM
QPN Level 5 ●●●●●
Forum|alt.badge.img+21
  • QPN Level 5 ●●●●●
  • March 3, 2021

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


Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • March 3, 2021

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.


  • Author
  • Answer
  • March 3, 2021

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