Simple Syntax for Form Work in Javascript

Hey everyone,

I’m looking to get a value from a textbox like so:

var textboxvalue = form.textboxname.value;

However, my “textboxname” is a variable that stores the name of the textbox. is there any way of doing this?

Help is appreciated. Thanks!
-IM Greg.

Yes there is, using the array-notation format.

[highlight="javascript’]
var textboxvalue = form.elements[textboxname].value;