I’m trying to figure out something in javascript that is just escaping me…
In a web form, I am trying to validate some fields when the user hits the Submit button, using the tag:
form name=myform onSubmit=”return validate()”
In the validate(myform) javascript I am trying to access the values that the user entered (in field “version”):
This works: alert(“version = ” + myform.version.value);
This gives an error:
var fieldname = “version”;
alert(“version = ” + myform.fieldname.value);
+++ myform.fieldname has no properties
How can I get “fieldname” to be evaluated BEFORE it figures out the address myform.fieldname.value?
Here’s what doesn’t work:
myform.fieldname.value
myform.(fieldname).value
myform.${fieldname}.value
Any thoughts? You guys are the best minds in the field! If you don’t know, then it can’t be done!