label text

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:

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:

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

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

Thanks!

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


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

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

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

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.

use:

elements[lblNames[0]]]['text'] 

or

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

Johan to the rescue!! Thanks!