0

Simple question. Is it possible to replace the following code:

document.form_name.element_name

with

document.form_name.<array[index].value>

?

3 Answers 3

4

Try this:

document.form_name[array[index].value];
Sign up to request clarification or add additional context in comments.

Comments

0
var my_element = "username";
document.form_name[my_element];

and

var fields = [ "username", "realname" ];
document.form_name[fields[0]];

Comments

0

assuming <array[index].value> has "element_name" in it, you can do the following:

document.form_name[array[index].value]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.