- Posts: 18
- Thank you received: 4
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify this question ID var qID = {QID}; // Build an array of subquestion codes var sqCodeArr = new Array(); $('#question'+qID+' table.question tbody tr').each(function(i) { var sqCode = $(this).attr('id').split('X'+qID+'')[1]; sqCodeArr.push(sqCode); }); // Find the highest code (alphabetically) sqCodeArr.sort(); var highCode = sqCodeArr[sqCodeArr.length-1]; // Now, move that subquestion to the bottom $('#question'+qID+' table.question tbody').append($('#question'+qID+' tr[id$="X'+qID+highCode+'"]')); }); </script>
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify this question var qID = {QID}; // Place the "DK" code option at the end of the list var answer = $( 'input[id$="X'+qID+'DK"]'); var answerItem = $(answer).closest('li'); var answersList = $(answer).closest('ul'); $(answersList).append(answerItem); }); </script>
<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>