title: javascript check radio buttons automatically
body: <p>I wanna check radio buttons automatically: I tried this code but it does not work:
  Radio buttons have 3 different values, I wanna select the radio button with value 'clean".</p>
  
  <p>How can I check automatically radio buttons on a webpage?
  Thanks!</p>
  
  <pre><code>function getElements()
    {
  
    for (i=0; i&lt;document.getElementsByTagName('input').length; i++) 
    {
      //if (document.getElementsByTagName('input')[i].type == 'radio')
      if(document.getElementsByTagName('input')[i].type=='radio')
      {
          //if (document.getElementsByTagName('input')[i].value=='clean')
          document.getElementsByTagName('input')[i].click();
      }
    }
  </code></pre>
  
  <p>I modified the code as following: </p>
  
  <pre><code> for (i=0; i&lt;document.getElementsByTagName('input').length; i++) 
    {
  
      if(document.getElementsByTagName('input')[i].type=='radio')
      {
  
  
          if(document.getElementsByTagName('input')[i].value == "clean")
          {
          document.getElementsByTagName('input')[i].checked =true;
          }
  
      }
    }
  </code></pre>
  
  <p>but it is not still working:(</p>
  
  <p>the radio buttons are in a iframe, can it be the reason why the code is not working?</p>