- Posts: 116
- Thank you received: 1
Ask the community, share ideas, and connect with other LimeSurvey users!
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
<script type="text/javascript" data-author="Tony Partner"> $(document).on('ready pjax:scriptcomplete',function(){ // The answer codes of item(s) to be fixed var fixedStartCodes = [1]; var fixedEndCodes = [4,5,6]; // Set this to "true" if you want "Other" to be fixed in the last position var otherFixed = false; // Identify this question var qID = '{QID}'; var thisQuestion = $('#question'+qID); // Fix the item(s) to the start $.each(fixedStartCodes, function(i, code) { $('.answer-item[id$="X'+qID+code+'"]').prependTo($('.answers-list ul:eq(0)', thisQuestion)); }); // Fix the item(s) to the end $.each(fixedEndCodes, function(i, code) { $('.answer-item[id$="X'+qID+code+'"]').appendTo($('.answers-list ul:eq(0)', thisQuestion)); }); // 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('ul'); $(otherAnswersList).append(otherAnswerItem); } }); </script>
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
<script type="text/javascript" data-author="Tony Partner"> $(document).on('ready pjax:scriptcomplete',function(){ // The answer codes of item(s) to be fixed var fixedStartCodes = [1]; var fixedEndCodes = [4,5,6]; // Set this to "true" if you want "Other" to be fixed in the last position var otherFixed = false; // Identify this question var qID = '{QID}'; var thisQuestion = $('#question'+qID); // Fix the item(s) to the start $.each(fixedStartCodes, function(i, code) { $('.answer-item[id$="X'+qID+code+'"]').prependTo($('.answers-list ul:eq(0)', thisQuestion)); }); // Fix the item(s) to the end $.each(fixedEndCodes, function(i, code) { $('.answer-item[id$="X'+qID+code+'"]').appendTo($('.answers-list ul:eq(0)', thisQuestion)); }); // 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('ul'); $(otherAnswersList).append(otherAnswerItem); } }); </script>
Please Log in to join the conversation.