Skip to content

Instantly share code, notes, and snippets.

@ciamarro
ciamarro / random_radio.js
Created July 7, 2017 13:07
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;