Check answers using Javascript | XM Community
Skip to main content
Question

Check answers using Javascript

  • 23 July 2024
  • 1 reply
  • 9 views

I want to check the correctness of my participants’ answers, which will determine later questions they get. 

Now, I’m trying to use this.getSelectedChoices() (and even better, with recoded values) and compare the selected choices with my correct answers for each question, but I realized that most previous posts suggest using this in the addOnPageSubmit function, which I don’t see anymore. 

So I was wondering how people go about this now?

1 reply

Userlevel 5
Badge +17

Hi @CindyJ. If you add some JavaScript to a question, the addOnPageSubmit does not show up in the method structure but you can still use it. Just add it to the JavaScript section and update it with the code.

Qualtrics.SurveyEngine.addOnPageSubmit(function()
{
/*Place your JavaScript here to run when the page is unloaded*/
// Your code 
});

If you need further assistance on the validation, I guess you need to provide more context about the detailed requirement. 

Best

Christian

Leave a Reply