# Get the text from an "input text field"

**URL:** <https://forum.kirupa.com/t/get-the-text-from-an-input-text-field/112003>\
**Category:** Uncategorized\
**Created:** [June 2, 2004, 2:33pm UTC](https://forum.kirupa.com/t/get-the-text-from-an-input-text-field/112003 "2004-06-02T14:33:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jajoho](https://avatars.discourse-cdn.com/v4/letter/j/a698b9/32.png) [@jajoho](https://forum.kirupa.com/u/jajoho)\
**Post date:** [June 2, 2004, 2:33pm UTC](https://forum.kirupa.com/t/get-the-text-from-an-input-text-field/112003/1 "2004-06-02T14:33:29Z")

</div>

Hello.

I’m trying to refer to the text in an input text field. The name of the fields are attr1, attr2, attr3… This works fine when I type;  
my\_mc.var1.text,  
my\_mc.var2.text…

In order not to type the name of all the fields,  
I want to do it in a loop, and put the results into an array;

[AS]  
for(i; i\<(number\_of\_attr+1); i++) {  
var nr = new LoadVars();  
var attr\_nr = new LoadVars();  
var suggestion = new LoadVars();

attr\_nr = i.toString();  
nr = “attr” + attr\_nr;

suggestion = main.nr.text;  
suggestion\* = suggestion;  
}  
[/AS]

nr = “attr” + attr\_nr;  
list attr1, attr2… as intended  
but I cant use this to refer to the textfield;  
main.nr.text; (get undefined when using this)

It only works when I type attr1, attr2 …

Please help. I’m new to this…
