Hi,
as this is a different question you should have opened a new thread.
But you can do it like this.
Code:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
function shuffleArray(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;
}
// Identify the questions
var thisQuestion = $('#question{QID}');
var thisQuestionID = {QID};
var str = $('#question{QID} input[type="text"]').val();
var arr = str.split(', ');
// Shuffle the array
arr=shuffleArray(arr);
anumbers = '#' + arr.slice(0,3).join(',');
// Load the hidden questions with items from the array
$('#question{QID} input[type="text"]').val(anumbers);
$('#question{QID}').hide();
});
</script>
Have a look at the default answer of "Q0a".
screenshots:
1. More than three brands
2. Less than three brands
You see the dynamic text?
Joffm