Javascript to set embedded data | XM Community
Skip to main content

Javascript to set embedded data

  • May 15, 2019
  • 2 replies
  • 19 views

Forum|alt.badge.img+1
This amazingly useful code that Tom posted (slightly modified now) works perfectly: Qualtrics.SurveyEngine.addOnPageSubmit(function() { var selectedRecode = this.getChoiceRecodeValue(this.getSelectedChoices()); var c = (selectedRecode >= "5") ? "Y" : "N"; Qualtrics.SurveyEngine.setEmbeddedData("Reduce alcohol flag", c); }); I have changed the selectedRecode from == to >=5 in order to include a range and this works fine. What I would like help with is how to allow the selectedRecode to be a number of different values such as 3, 4 and 9 as an example?

2 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • May 15, 2019
Use JavaScript if else or switch.

Forum|alt.badge.img+1
  • Author
  • May 16, 2019
Thanks Tom - I have it working now. Sorry if the question was a bit simple but I am new to JavaScript - these snippets really transform the basic Qualtrics (which is very good anyway). So thanks again.