Skip to content

Instantly share code, notes, and snippets.

@ciamarro
Created July 7, 2017 13:07
Show Gist options
  • Save ciamarro/2591258d697ac2a13d5148b1caa3202e to your computer and use it in GitHub Desktop.
Save ciamarro/2591258d697ac2a13d5148b1caa3202e to your computer and use it in GitHub Desktop.
Randomly select all radio buttons on a form
var a = document.querySelectorAll('input[type=radio]');
for (var i=0; i<a.length; i++)
// from https://stackoverflow.com/a/18066088/8148848
a[i].checked = ( (Math.random()*10) > 5) ? true : false;
@vishalsainioffical
Copy link

hii can only chacked 10 rendom only

@vishalsainioffical
Copy link

can limit the generate random
eg- all radio input is 50
when click on button chacked only rendom 10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment