title: Error document.form is undefined in javascript
body: <p>I have a code javascript:</p>
  
  <pre><code>&lt;form onsubmit="return false;" action=""&gt;
  &lt;input type="radio" name="type" id="type0" value="0" onclick="toggleSet(this)" checked /&gt;type 0
  &lt;input type="radio" name="type" id="type1" value="1" onclick="toggleSet(this)" /&gt;Type 1
  &lt;/form&gt;
  &lt;script&gt;
  function toggleSet() {
      for(var i=0; i&lt;document.form.type.length; i++) {
          if(document.form.type[i].checked) {
              var type = document.form.type[i].value;
          }
      }
      alert(type);
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>ouput error: document.form is undefined, how to fix it ?</p>