Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Workaround to display secondary options in "multiple options with comment"

  • ziyaei_f
  • ziyaei_f's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 3 months ago #177676 by ziyaei_f
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
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose