- Posts: 61
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:complete',function() { // Define the subquestion code to be fixed at the bottom of the array var fixedCode = 'SQ004'; // Move that row to the bottom $('#question{QID} table.subquestion-list tbody:eq(0)').append($('tr[id$="X{QID}'+fixedCode+'"]')); // Fix up the row background colours $('#question{QID} tr.answers-list').each(function(i){ $(this).removeClass('ls-even, ls-odd'); if(i % 2 == 0) { $(this).addClass('ls-even'); } else { $(this).addClass('ls-odd'); } }); }); </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; // Set this to "true" if you want "Other" to be fixed in the last position var otherFixed = false; // Identify this question var qID = {QID}; // Find the number of answers var ansCount = $('#question'+qID+' .answer-item').length; if($('#question'+qID+' input[type="text"]').length > 0) { ansCount = ansCount -1 } // 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 = $('input[id^="answer"][id$="X'+qID+'s'+(ansCount-fixedIndex)+'"]'); var answerItem = $(answer).closest('.answer-item'); var answersList = $(answer).closest('.answers-list'); if($('#question'+qID).hasClass('multiple-opt')) { answer = $('input[id^="answer"][id$="X'+qID+(ansCount-fixedIndex)+'"]'); answerItem = $(answer).closest('.answer-item').parent(); answersList = $(answer).closest('.subquestion-list'); } $(answersList).append(answerItem); fixedIndex--; } // Handle "Other" if(otherFixed == true && $('#question'+qID+' input[type="text"]').length > 0) { var otherAnswer = $('#question'+qID+' input[type="text"]'); var otherAnswerItem = $(otherAnswer ).closest('.answer-item'); var otherAnswersList = $(otherAnswer ).closest('.answers-list'); if($('#question'+qID).hasClass('multiple-opt')) { otherAnswerItem = $(otherAnswer ).closest('.answer-item').parent(); otherAnswersList = $(otherAnswer ).closest('.subquestion-list'); } $(otherAnswersList).append(otherAnswerItem); } }); </script>
What is not working???and also not working, please advice.