- Posts: 10226
- Thank you received: 3641
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ // Move sub-question codes 97, 98, 99 to the end of the array $('#question{QID} table.subquestions-list tbody').append($('#question{QID} table.subquestions-list tr[id$="X{QID}97"]')) .append($('#question{QID} table.subquestions-list tr[id$="X{QID}98"]')) .append($('#question{QID} table.subquestions-list tr[id$="X{QID}99"]')); // Fix up array row background colours $('#question{QID} table.subquestions-list tbody > tr').each(function(i){ $(this).removeClass('array1 array2').addClass('array'+(2-(i%2))); }); }); </script>
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ // Move sub-question codes 12, 13 to the end of the array $('#question{QID} .subquestions-list ').append($('#question{QID} .subquestions-list div[id$="X{QID}12"]').parent() ).append($('#question{QID} .subquestions-list div[id$="X{QID}13"]').parent() ); }); </script>
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // The number of answers to be fixed at the end of the list var fixedAnswers = 2; // Identify this question var qID = {QID}; // Find the number of answers var ansCount = $('#question'+qID+' .answers-list').length; //alert(ansCount); // Place the last n answers created at the end of the list var fixedIndex = fixedAnswers - 1; for (var i=0; i<fixedAnswers; i++) { var answer = $('tr[id$="X'+qID+(ansCount-fixedIndex)+'"]'); var table = $('table.subquestion-list'); $(table).append(answer); fixedIndex--; } // Update the classes of the odd and even rows for the css for (var i=0; i<ansCount; i++) { var answer = $('tr.answers-list:eq('+i+')'); var evenOrOdd = i %2; if(evenOrOdd==1) { if ($(answer).hasClass('array2')) { $(answer).removeClass('array2'); $(answer).addClass('array1'); } } if(evenOrOdd==0) { if ($(answer).hasClass('array1')) { $(answer).removeClass('array1'); $(answer).addClass('array2'); } } } }); </script>