- Posts: 18
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify this question var thisQuestion = $('#question{QID}'); // Define the sub-heading text strings var subHeading1 = 'Fruits'; var subHeading2 = 'Vegetables'; var columnsLength = $('tr.answers-list:eq(0) > *', thisQuestion).length; // Insert the new rows $('tr.answers-list:eq(0)', thisQuestion).before('<tr class="sub-header-row"><th colspan="'+columnsLength+'">'+subHeading1+'</th></tr>'); $('tr.answers-list:eq(3)', thisQuestion).before('<tr class="sub-header-row"><th colspan="'+columnsLength+'">'+subHeading2+'</th></tr>'); // Fix up the row classes var rowClass = 1; $('table.subquestions-list tbody tr', thisQuestion).each(function(i) { if($(this).hasClass('sub-header-row')) { rowClass = 1 } else { rowClass++; $(this).removeClass('array1 array2') if(rowClass % 2 == 0) { $(this).addClass('array2'); } else { $(this).addClass('array1'); } } }); }); </script> <style type="text/css">.sub-header-row { margin-bottom: 20px; } .sub-header-row th { background-color: #efefef; color: #000000 !important; text-align: left; } </style>
<script charset="utf-8" type="text/javascript"> $(document).ready(function() { $( '#question{QID} .question-item:eq(0)').addClass('hide-pseudo-elements').find('input.checkbox').remove(); $( '#question{QID} .question-item:eq(4)').addClass('hide-pseudo-elements').find('input.checkbox').remove(); $( '#question{QID} .question-item:eq(0)').addClass('hide-pseudo-elements').find('.comment-container').remove(); $( '#question{QID} .question-item:eq(4)').addClass('hide-pseudo-elements').find('.comment-container').remove(); }); </script> <style type="text/css">.hide-pseudo-elements label::before, .hide-pseudo-elements label::after { display: none; } .hide-pseudo-elements .label-text { margin-left: -20px; } </style>
Use sub-question relevance instead of array-filter to hide/show the rows in question B.but then how to be sure that no category will be shown on question B in case nothing is selected (let's say no one selected any fruit, I do not want the category "fruit" to appear empty on the next question)
!is_empty(Q1_SQ002) OR !is_empty(Q1_SQ003) OR !is_empty(Q1_SQ004)