Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Random question - excluding the ones that already came

  • Rob_Berlin
  • Rob_Berlin's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 9 months ago #122003 by Rob_Berlin
Hello,

I´ve spent quite some time searching, but nothing seems to work, so maybe someone can help me. Here is what I want to do:
I want to have a pool of 4 questions, wwith randwom order. I tried this with rand(1,4) and it works. However the second question should be out of thats same pool, but without the number of the previous one. So let´s say the first question was number 2 and now I want to draw randomly from a pool of question 1, 3 and 4.
I assume that with the implemented functions this wont work, so I tried a skript with a while loop. For whatever reasons my skript never seems to work.
This is what I used:
Code:
<script type="text/javascript" charset="utf-8">
 
        $(document).ready(function() {
 
rand2=rand(1,4);
while (rand2==rand1) { 
rand2=rand(1,4); 
}
}
</script>

Thanks a lot for your help!
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose