- Posts: 2
- Thank you received: 0
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.
herefore, rand() does not work.
,if(is_empty(r4),rand(1010,1040),r4),if(is_empty(r4),rand(1100,1200),r4))))}<script type="text/javascript" charset="utf-8"> function shuffle(array) { var currentIndex = array.length, temporaryValue, randomIndex; // While there remain elements to shuffle... while (0 !== currentIndex) { // Pick a remaining element... randomIndex = Math.floor(Math.random() * currentIndex); currentIndex -= 1; // And swap it with the current element. temporaryValue = array[currentIndex]; array[currentIndex] = array[randomIndex]; array[randomIndex] = temporaryValue; } return array; } $(document).on('ready pjax:scriptcomplete',function(){ // Fill the array var arr = []; for (var i = 850; i < 901; i++) { arr.push(i); } for (var i = 960; i < 991; i++) { arr.push(i); } for (var i = 1010; i < 1041; i++) { arr.push(i); } for (var i = 1100; i < 1201; i++) { arr.push(i); } arr = shuffle(arr); anumbers = arr.slice(0,1).join(''); $('#question{QID} input[type="text"]').val(anumbers); // After testing remove the slashes to hide the question // $('#question{QID}').hide(); }); </script>
Please Log in to join the conversation.
Please Log in to join the conversation.