- Posts: 9
- 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 this question var thisQuestion = $('#question{QID}'); // Hide this question (un-comment below) //thisQuestion.hide(); var numbers = [1,2,3,4,5]; // A function to shuffle elements or contents of arrays (function($){ $.fn.shuffle = function() { return this.each(function(){ var items = $(this).children(); return (items.length) ? $(this).html($.shuffle(items)) : this; }); } $.shuffle = function(arr) { for( var j, x, i = arr.length; i; j = parseInt(Math.random() * i), x = arr[--i], arr[i] = arr[j], arr[j] = x ); return arr; } })(jQuery); // Shuffle the array numbers = $.shuffle(numbers); //Load the first three array values and fire Expression Manager $('input.text', thisQuestion).each(function(i) { $(this).val(numbers[i]); checkconditions(this.value, this.name, this.type); }); }); </script>