- 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() { // 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>