Jump to content

Recommended Posts

Im trying to figure out how to click say random 16 check boxes of say 48 in a form, its for a role playing game that has questions that you can either fill out or in most lazy peoples case just random answer to get your class, but i cant seem to figure out how to pick 16 answers on random on one form thank you

Link to comment
https://forums.phpfreaks.com/topic/154397-random-help/
Share on other sites

maybe something like this (may have a few bugs, As I didn't test it):

 

var myArray = new Array();
function in_array(val){
     for(var i=0;i<myArray.length;i++){
          if(myArray[i] == val) return true;
     }
     return false;
}
function randomCheck(){
     var i = 0;
     while(myArray.length < 48){
          var ran = round(Math.random()*48);
          if(!in_array(ran)) {
               myArray[i] = ran;
               i++;
          }
     }
}

Link to comment
https://forums.phpfreaks.com/topic/154397-random-help/#findComment-811906
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.