I’m creating a survey where I have conditional logic based on the answers to the first question. Based on the answers selected, I will populate additional questions. I’d like to use a repeater to show the additional questions, and each of those questions are a multi checkbox question.
However, I’m having trouble getting the value of the multi check box on change. This worked before with a slider, but it’s not working with a multi checkbox. Here’s my code below:
$w( ‘#multipleChoiceQuestion’ ).onChange(event => { let updatedSelections = event.syntheticEvent.value;
console.log( "Answer options changed to " +updatedSelections);;
dataset.setFieldValue(propertyName, updatedSelections);
})
This time, in the event object, I can’t seem to find the answer options that have been selected by the user on the fly. I need to do this so I can store the checked answers into the correct property in the data collection (and also retrieve if a user clicks a back button).
Any guidance on this? Really hoping to use a repeater so I only have to format this bank of questions once.
This is brilliant! Yes the combination of these two comments fixed my problem I think completely. For folks that would benefit from seeing what worked, I needed to embed the selectedIndices method into the onItemReady function for my repeater. Before I did that, selectedIndices was returning the selected options of the dummy placeholder question that I was overwriting in my repeater. Updated code: