- Posts: 6
- 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(){ //Identify the questions var thisQuestion = $('#question{QID}'); var hiddenQuestion = $(thisQuestion).nextAll('.text-short:eq(0)'); // Create an array of answer codes var answerCodes = []; $('.answer-item', thisQuestion).each(function(i) { answerCodes.push($(this).attr('id').split('X{QID}')[1]); }); // Load the hidden question $('input:text', hiddenQuestion).val(answerCodes); }); </script>
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ //Identify this question var thisQuestion = $('#question{QID}'); // Determine the number of items in the first column var rowCount = $('.answers-list.multiple-list > ul:eq(0) .question-item', thisQuestion).length; // Retrieve the answer codes from the "randomOrder" question var answerCodes = '{randomOrder}'.split(','); console.log(answerCodes); // Loop through the answer codes var row = 0; var column = 0; $.each(answerCodes, function(i, val) { // Move the answer item $('.answers-list.multiple-list > ul:eq('+column+')', thisQuestion).append($('.answer-item[id$="X{QID}'+val+'"]', thisQuestion)); if(row < (rowCount-1)) { row++; } else { // Increment the column row = 0; column++; } }); }); </script>