- Posts: 13661
- Thank you received: 4188
Ask the community, share ideas, and connect with other LimeSurvey users!
LimeSurvey does not store the order. So how do you decide which are the "first 5"?Of the selected brands, I am only taking the first 5 to apply my next questions, which are Q21 and Q21a.
<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(){ var strp=$('#question{QID} input[type="text"]:eq(0)').val().replace(/\s+/g, ''); var stro=$('#question{QID} input[type="text"]:eq(1)').val().replace(/\s+/g, ''); // Fill the arrays var arrp = strp.split(','); var arro = stro.split(','); // Shuffle and truncate arrp = shuffle(arrp); arrp = arrp.slice(0,5).join(''); arro = shuffle(arro); arro = arro.slice(0,5).join(''); // Fill the subquestion with the results $('#question{QID} input[type="text"]:eq(0)').val(arrp); $('#question{QID} input[type="text"]:eq(1)').val(arro); $('#ls-button-submit').trigger('click'); }); </script>
Please Log in to join the conversation.
Please Log in to join the conversation.
Exactly, this is what the "list" function does.it registers commas to separate each brand
Please Log in to join the conversation.
Please Log in to join the conversation.
so my solution is to only have 10 fixed variables and show the ones that I have selected in Q13a,
And nowOf the selected brands, I am only taking the first 5 to apply my next questions, which are Q21 and Q21a.
In these two questions, the 5 brands that they selected in Q13a are evaluated, but Q21 only applies to physical brands and Q21a only to online brands.
but I realized that there are many brands that handle both modalities, both physical and online.
Please Log in to join the conversation.
Please Log in to join the conversation.