View Full Version : Get value of input field and set as variable

12-24-2008, 04:12 AM
Hello, I'm trying to grab the value of an input form, and set it as a variable..
Here is the text field
<input name="email" id="email" type="text" size="35" value="email@email.com"/>

I'm not sure on how to do this
email = win.document.getElementById('email');

Would that be correct?

Thanks in advance!

12-24-2008, 04:42 AM
var email = document.getElementById('email').value;
or if you have only one element named 'email':
var email = document.getElementsByName('email')[0].value;