Hello to all,
I need help. I am so confused with my template. actually I am so basic in JS and used the
this workaround to display secondary options in "multiple options" question
but now I have to change my question type from "multiple options" to "multiple options with comment" and this code doesn't work for this type. Can anyone help me how can I edit the code to work for this new type of question?
here is also the code of workaound, which I used:
function secondaryCheckboxes(qID, primaryPosition, secondaryCount) {
// Identify the elements
var thisQuestion = $('#question'+qID);
var primaryRow = $('li.question-item:eq('+(primaryPosition-1)+')', thisQuestion).closest('li.question-item');
var primaryInput = $('input:checkbox', primaryRow);
var secondaryRows = primaryRow.nextAll('li.question-item:lt('+(secondaryCount)+')');
var secondaryInputs = $('input:checkbox', secondaryRows);
// Indent the secondaries
secondaryRows.css({ 'margin-left':'2.5em' });
// Initial states of the secondary answers
if (primaryInput.prop('checked') == false ) {
secondaryRows.hide();
}
// A listener on the primary answer to show or hide secondary answers
primaryInput.on('change', function (event) {
// Hide/show the secondary answers accordingly
if (!$(this).is(':checked')) {
secondaryRows.hide();
secondaryInputs.prop('checked', false).trigger('change');
}
else {
secondaryRows.show();
}
});
}
Thanks,
Marjan