title: JavaScript problem: getElementsByName() doesn't work for me
body: <p>Just trying to alert the value entered in the phone field, but it alerts undefined:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
  function foo() {
     alert(document.getElementsByName("phone").value);
     return false;
  }
  
  &lt;/script&gt;
  
  &lt;form action="foo.php" method="post" onsubmit="return foo()"&gt;
      &lt;label&gt;Name:&lt;/label&gt;
      &lt;input type="text" name="name" /&gt;
      &lt;label&gt;Phone:&lt;/label&gt;
      &lt;input type="text" name="phone" /&gt;
      &lt;label&gt;Email:&lt;/label&gt;
      &lt;input type="text" name="email" /&gt;
      &lt;label&gt;Message:&lt;/label&gt;
      &lt;textarea name="message"&gt;&lt;/textarea&gt;
      &lt;input type="submit" value="Submit" name="submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>How to get it to work? Also, I read that getElementsByName is supported in all major browsers, is that true?</p>