Dynamically assign value to hidden fields?

Giganews Newsgroups
Subject: Dynamically assign value to hidden fields?
Posted by:  br…@melendy.com (Brad Melendy)
Date: 25 Jul 2003

I have a function that among other things, assigns a value to a hidden
field element.  However, I want to pass the name of a hidden field to
my function and then assign it a value.  So instead of this:

document.forms[0].elements[4].value = "this is a test";

I want to be able to do something like this:

document.forms[0].+MyVarName+.value = "this is a test";

Where MyVarName is the name of the field at position 4 in the array of
form elements.

Does anyone know if this is possible?  When I try to do this I
generate an error.  Thanks for any help!