javascript get element by name
<p>Ok i have this little cute code as a expirement:</p>

<pre><code>function validate()
{
var acc = document.getElementsByName('acc').value;
var pass = document.getElementsByName('pass').value;

alert (acc);
}
</code></pre>

<p>and this html part</p>

<pre><code>&lt;table border="0" cellpadding="2" cellspacing="0" valign="top"&gt;
    &lt;tr&gt;
        &lt;td class="td1"&gt;Account&lt;/td&gt;
        &lt;td class="td2"&gt;&lt;input type="text" name="acc" /&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr class="td1"&gt;
        &lt;td&gt;Password&lt;/td&gt;
        &lt;td class="td2"&gt;&lt;input type="password" name="pass" /&gt;&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;
&lt;div&gt;&lt;button onClick="validate()" class="cupid-greenx"&gt;Login now&lt;/button&gt;&lt;/div&gt;
</code></pre>

<p>yes its working, the alert box is showing but the problem is, the value of input("name:acc")
is not showing as i specified that it must show whenever it gets the value of that input box instead it shows  "undefined" on the alert box. thanks in advance.</p>
