title: Attach event listener through javascript to radio button
body: <p>I have several radio buttons with the same name. Like this:</p>
  
  <pre><code>&lt;form name="formA"&gt;
  &lt;input type="radio" name="myradio" value="A"/&gt;
  &lt;input type="radio" name="myradio" value="B"/&gt;
  &lt;input type="radio" name="myradio" value="C"/&gt;
  &lt;input type="radio" name="myradio" value="D"/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Now I have to add event listener through javascript to all the radio buttons. If the below pseudocode is wrong, then please tell me how to do it-</p>
  
  <pre><code>var radios = document.forms["formA"].elements["myradio"];
    for(radio in radios) {
      radio.onclick = function() {
          alert(radio.value);
      }
  }
  </code></pre>