title: How to AutoFill/Populate Radio-Button-Based Forms
body: <p>I'm mostly a coding noob, but I was wondering if anybody can get me started on being able to autofill radio buttons with JS.</p>
  
  <p>I was able to find this bit of code:</p>
  
  <pre><code>javascript:(function()%7Bvar W=%5B%5D,V=Math.random,U=Math.floor,T,S,R,Q,P='password',O=U(V()*9e6),N=O+'@example.com';function M(L,H)%7Btry%7BH=L.document.getElementsByTagName(H)%7Dcatch(e)%7BH=%5B%5D%7Dfor(i=0;i&lt;H.length;i++)%7BT=H%5Bi%5D;if(T.readOnly%7C%7CT.disabled)continue;S=T.name;R=T.type;Q=T.value;if('checkbox'==R)T.checked=V()&gt;.5;if(P==R)Q=O;if('text'==R)%7BQ=U(V()*9e6);if(S.match(/mail/i))Q=N%7DT.value=Q;if('radio'==R)%7Bif(!++W%5BS%5D)W%5BS%5D=1;T.checked=V()&lt;(1/W%5BS%5D)%7Dif(R.match(/%5Eselect/))T.selectedIndex=V()*(T.options.length-1)+1%7Dif(T)try%7BT.focus()%7Dcatch(e)%7B%7D%7Dfunction G(L)%7BM(L,P);M(L,'select');M(L,'input');for(var i=0;i&lt;L.frames.length;i++)%7BG(L.frames%5Bi%5D)%7D%7DG(window)%7D());void(0)
  </code></pre>
  
  <p>This code only autopopulates randomly and doesn't appear to bubble on sites like surveymonkey and qualtrics. Personally, I'd like to be able to autofill 5-question radio buttons/selections to the 4th value every time - I want the 4th radio button selected per question, on pages with multiple questions, too. Since for most 5-choice answers the 4th choice has the highest percentage of being correct, I figure this will save some time here and there.</p>
  
  <p>If there is any bits of code or resources I can be directed to, that would be awesome! Thanks guys.</p>