# label text

**URL:** <https://forum.servoy.com/t/label-text/14664>\
**Category:** Classic Servoy\
**Created:** [September 14, 2011, 10:36pm UTC](https://forum.servoy.com/t/label-text/14664 "2011-09-14T22:36:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gldni](https://avatars.discourse-cdn.com/v4/letter/g/7ea924/32.png) [@gldni](https://forum.servoy.com/u/gldni)\
**Post date:** [September 14, 2011, 10:36pm UTC](https://forum.servoy.com/t/label-text/14664/1 "2011-09-14T22:36:34Z")

</div>

I want to get the text values from labels on my form and put those text values in an array. So far I have gotten the names of the labels:

```auto
for(var b = 0; b < elements.allnames.length; b++)
	{
		if(elements.allnames[b].indexOf('lbl_') === 0)
		{
			lblNames.push(elements.allnames[b]);
		}
	}

```

The following code works, but it didn’t give me option using auto-complete so I’m sure I’m doing something I’m not supposed to:

```auto
lblText.push(elements[lblNames[0]].text);

```

What is the correct way to get my array of label text?

Thanks!

---

<div class="post-metadata">

**Author:** ![mboegem](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/mboegem/32/4399_2.png) [@mboegem](https://forum.servoy.com/u/mboegem)\
**Post date:** [September 15, 2011, 11:08am UTC](https://forum.servoy.com/t/label-text/14664/2 "2011-09-15T11:08:34Z")

</div>

I’d just declare the array before starting the for-loop.  
So: ```  
var lblText = new Array()

```auto

Then within the loop you can just extend the array like:

```

lblTxt[lblTxt.length] = elements[lblNames[0]].text

```auto

```

---

<div class="post-metadata">

**Author:** ![gldni](https://avatars.discourse-cdn.com/v4/letter/g/7ea924/32.png) [@gldni](https://forum.servoy.com/u/gldni)\
**Post date:** [September 15, 2011, 3:03pm UTC](https://forum.servoy.com/t/label-text/14664/3 "2011-09-15T15:03:12Z")

</div>

Thanks for the reply, Marc. I’ll give this a try:

```auto
lblTxt[lblTxt.length] = elements[lblNames[0]].text

```

But is “elements[lblNames[0]].text” correct? When I type in elements[lblNames[0]]. and hit ctrl+space for auto-complete, “text” isn’t one of my choices. I get “bgcolor”, “border”, “enabled”, “fgcolor”, “visible”, and a few functions, but “text” isn’t there. If you ignore auto-complete and add the “.text” it does give me the value I want.

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [September 15, 2011, 3:09pm UTC](https://forum.servoy.com/t/label-text/14664/4 "2011-09-15T15:09:32Z")

</div>

use:

```auto
elements[lblNames[0]]]['text'] 

```

or

```auto
/** @type {RuntimeLabel} */
var label = elements[lblNames[0]]]
label.text;

```

---

<div class="post-metadata">

**Author:** ![gldni](https://avatars.discourse-cdn.com/v4/letter/g/7ea924/32.png) [@gldni](https://forum.servoy.com/u/gldni)\
**Post date:** [September 15, 2011, 3:25pm UTC](https://forum.servoy.com/t/label-text/14664/5 "2011-09-15T15:25:23Z")

</div>

Johan to the rescue!! Thanks!
