I have a multiple choice question (Yes/No) where Yes correlates to a score of 0 and No correlates to a score of 1. I've used the "Recode Values" feature to set Yes to 0 and No to 1. This is inside a loop/merge block, so I cannot use the Scoring feature or Embedded Data/Branching in Survey Flow.
My code currently looks like this:
Qualtrics.SurveyEngine.addOnPageSubmit(function() {
var answer = jQuery("#"+this.questionId+".q-checked").val();
Qualtrics.SurveyEngine.setEmbeddedData('answer', answer);
if(answer = 0) Qualtrics.SurveyEngine.setEmbeddedData('mmm', '0');
if(answer = 1) Qualtrics.SurveyEngine.setEmbeddedData('mmm', '1');
});
I have also tried:
Qualtrics.SurveyEngine.addOnPageSubmit(function() {
var answer = this.questionContainer.querySelector(".q-checked").nextElementSibling.innerText;
Qualtrics.SurveyEngine.setEmbeddedData('answer', answer);
if(answer = 0) Qualtrics.SurveyEngine.setEmbeddedData('mmm', '0');
if(answer = 1) Qualtrics.SurveyEngine.setEmbeddedData('mmm', '1');
});
Inside the same block after this question, I have a page break and then two questions with display logic. If they answer Yes/get a score of 0 on the preliminary question, it should display Question A. If they answer No/get a score of 1 on the preliminary question, it should display Question B.
My code seems to set their score to 1 and display Question B no matter if they answer Yes or No to the preliminary question.
Thank you in advance for any help.