Code customized feedback in Qualtrics | XM Community
Skip to main content

Code customized feedback in Qualtrics

  • February 21, 2023
  • 2 replies
  • 14 views

Forum|alt.badge.img

Hello,
I am currently coding my thesis experiment and can't figure out how to code individual feedback for single questions. More specifically, I have several questions in a matrix and depending on whether the participant responds with "yes" a customized feedback should appear in a typing effect next to the question (it should appear to the participant like someone else is virtually responding to the participant's response in real-time) . When the participants responds with "no" different feedback should appear. I think the best ways is to use JavaScript and define if statements for every questions. However, my code it not working. Your help is much appreciated and needed!

2 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • February 21, 2023

Post your code.


Forum|alt.badge.img
  • Author
  • February 22, 2023

Hey TomG
Thanks for the quick response and your help!
Here is the JavaScript code:

function typeWriter() {
   if (i < txt.length) {
     document.getElementById("demo").innerHTML += txt.charAt(i);
     i++;
     setTimeout(typeWriter, speed);
   }
 }
var i = 0;
 var speed = 100;
var a = "Was the gray-haired man’s name Louis?"; 
if (a=="Yes") {
 var txt = "I agree";
} else if (a=="No") {
 var txt = "I do not agree";
typeWriter();