title: JavaScript Form Detection
body: <p>I want to detect the when the 'yes' radio button is chosen with JavaScript. This is a small lightweight form and does not have jQuery or other library installed. My goal is for it to work in most major browsers and be written in just a few lines of code.</p>
  
  <pre><code>   &lt;script type="text/javascript"&gt;
          if(document.forms[0].test.buy){alert("Clicked yes.);
     &lt;/script&gt; 
  
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form name="test"&gt;
          Buy Ice cream?
          &lt;input type="radio" name="buy" value="yes" /&gt; Yes
          &lt;input type="radio" name="buy" value="no" /&gt; No&lt;br /&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>