Dynamic statements javascript | XM Community
Skip to main content
Solved

Dynamic statements javascript

  • January 27, 2025
  • 3 replies
  • 26 views

Forum|alt.badge.img+1

I need to get a matrix question statements populated dynamically. The statements will be included in a contact list field separated by commas. I think the best way to get this done is using javascript. Any ideas on this? Thank you.

Best answer by TomG

Yes,  you can parse the list and save the items to embedded data fields.  Then pipe those fields into your matrix on a subsequent page:

Qualtrics.SurveyEngine.addOnload(function() {
  "${e://Field/cslist}".split(",").forEach(function(val,i) {
     Qualtrics.SurveyEngine.setEmbeddedData("stmt"+(i+1),val);
  });
});

 

View original

3 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5929 replies
  • Answer
  • January 27, 2025

Yes,  you can parse the list and save the items to embedded data fields.  Then pipe those fields into your matrix on a subsequent page:

Qualtrics.SurveyEngine.addOnload(function() {
  "${e://Field/cslist}".split(",").forEach(function(val,i) {
     Qualtrics.SurveyEngine.setEmbeddedData("stmt"+(i+1),val);
  });
});

 


Forum|alt.badge.img+1
  • Author
  • Level 1 ●
  • 5 replies
  • January 27, 2025

Great! Is there a way to skip the pipe action (manually) and automatically populate statements in the matrix question using the generated embedded data fields?


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5929 replies
  • January 27, 2025
mc1999 wrote:

Great! Is there a way to skip the pipe action (manually) and automatically populate statements in the matrix question using the generated embedded data fields?

Yes, you can update the innerHTML of the labels.  You still might want to set embedded data fields to record what statements were shown to the respondents.


Leave a Reply