More about dates and JavaScript | XM Community
Skip to main content

Hello again:
I'm making a bit of progress, but am still struggling with the Qualtrics Variable Names.
Here is my updated code:
Qualtrics.SurveyEngine.addOnSubmit(function()
{


      function dateproduce(x) {
  const myArray1 = x.split(".")
  var y1 = myArray1r1];
         var m1 = myArray1=0]-1;
         if(m1==-1) {
  m1 = 12;
  y1 = y1 - 1;
}
      var dt1 = new Date(y1,m1);
  return dt1;
      }
      var st =  "${q://QID3%231/ChoiceTextEntryValue/1/1}";
  console.log(st) 
      let dta1 = dateproduce(st);
      var et =  "${q://QID3%232/ChoiceTextEntryValue/1/1}";
      let dta2 = dateproduce(et);
      if(dta2 < dta1)
  Qualtrics.SurveyEngine.setEmbeddedData('FinalResponse',"incorrect");
      else
  Qualtrics.SurveyEngine.setEmbeddedData('FinalResponse',"correct");



});
```
The FinalResponse is not getting any value.
Any suggestions much appreciated.
Sincerely,
Erin
qual1.png

I'm not sure but did you try consoling these values on ready?


The function name should be addOnPageSubmit(). However, since you aren't a getting any data from the page itself, you might as well use addOnload(). That way you don't have to click Next to see what you've logged to the console.


Leave a Reply