I\'ve been using
document.forms[0].fieldname.value
to get values in javascript from a form, but I\'d like to use a name to reference the f
(document.forms is still supported. You can keep it.)
The best way to to give the field an id and use document.getElementById.
...
document.getElementById("fooId").value;
If you can't add an id, you can still use document.getElementsByName, but it will return an array instead of a single element because many may share the same name.
document.getElementsByName("fooName")[0].value;