[thelist] javascript argument in form object

.jeff jeff at members.evolt.org
Mon May 6 23:13:01 CDT 2002


david,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Denis, David
>
> function foo(formElementName) {
> 	document.myForm.formElementName.value = "foo";
> }
>
> this won't work.  How do I pass an argument into a
> form object?
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

there are several ways actually.

document.myForm[formElementName].value
document.myForm.elements[formElementName].value

obviously the second one is alittle more typing, but eminently easier to
read later on.  there's no doubt that you're referring to a form field.

good luck,

.jeff

http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/





More information about the thelist mailing list