How do I change the value of embedded data on a button click? | XM Community
Skip to main content
Solved

How do I change the value of embedded data on a button click?

  • January 11, 2019
  • 1 reply
  • 255 views

I have a button that I paste into the HTML view section of my question text. <button id="myButton" onclick="myFunction()">Click me</button> I have the following code in the "Edit Question JavaScript" area: Qualtrics.SurveyEngine.addOnReady(function() { /*Place your JavaScript here to run when the page is fully displayed*/ $('#myButton').on('click', () => { /* change embedded data */ Qualtrics.SurveyEngine.setEmbeddedData("clickedButton", "yes"); }); }); And I also created the embedded data variable clickedButton at the start of the survey, with value set to "no". The problem is, even when I click the button, the value of clickedButton is still equal to no. What can I do to rectify this?

Best answer by Anonymous

Hello @triple_w , Use the below code jQuery('#myButton').on('click', () => { /* change embedded data */ Qualtrics.SurveyEngine.setEmbeddedData("cb", "yes"); });
View original

1 reply

  • 0 replies
  • Answer
  • January 11, 2019
Hello @triple_w , Use the below code jQuery('#myButton').on('click', () => { /* change embedded data */ Qualtrics.SurveyEngine.setEmbeddedData("cb", "yes"); });

Leave a Reply