Hello,
There are 3 single choice questions which I number 1, 2 and 3. Question 1 has two possible answers A and B.
I am trying to write a java script such that:
- question 2 is displayed only if question 1 answer is A.
- question 3 is displayed only if question 1 answer is B.
- Questions 2 or question 3 are displayed on the same page as question 1.
- If a respondent changes answer to question 1 from A to B, the previously provided answer to question 2 clears. Similarly, if a respondent changes answer to question 1 from B to A, the previously provided answer to question 3 clears
I can do parts i, ii, and iii but cannot figure out part iv.
I circling around the following java code for question 2:
Qualtrics.SurveyEngine.addOnReady(function()
{
jQuery("#QID1").on('change', function(){
var LegChoices = "${q://QID1/SelectedChoicesRecode}";
var that = this;
LegChoices.split(",").each(function(LegChoice,index) {
var LegChoice = parseInt(LegChoice.trim());
if (LegChoice!=1) {
that.setChoiceValueByRecodeValue(1,false);
that.setChoiceValueByRecodeValue(2,false);
that.setChoiceValueByRecodeValue(3,false);
that.setChoiceValueByRecodeValue(4,false);
that.setChoiceValueByRecodeValue(5,false);
that.prop("checked", false)
}
})
});
})