elements

Overview

The elements property is a top-level runtime feature in form scopes that provides access to all elements of a form. It allows for interaction with elements either by their names or by their indices. This property is versatile, offering methods to retrieve the names of all form elements as an array and to fetch elements individually.

Features

The elements property offers access to elements through two main methods: indexed by name or by position. An array of all element names is accessible via the allnames property, and the total number of elements can be determined using the length property. These capabilities allow for dynamic interaction with form elements at runtime, enhancing flexibility in customizing and managing forms.

The property is universally supported across multiple clients, including Mobile, Web, Smart, and NG Client environments, making it a powerful tool in Servoy applications.

Properties Summarized

Type
Name
Summary

Get an element of the form by its index.

Get an element of the form by its name.

Get the names of all elements of the form, as an array.

Get the number of elements of the form.

Properties Detailed

[index]

Get an element of the form by its index.

Type RuntimeComponent

Sample

for (var i=0; i<elements.length; i++)
{
	var elem = elements[i];
	application.output(elem.getName() + ": " + elem.getDataProviderID());
}

[name]

Get an element of the form by its name.

Type RuntimeComponent

Sample

for (var i=0; i<elements.allnames.length; i++)
{
	var name = elements.allnames[i];
	var elem = elements[name];
	application.output(name + ": " + elem.getDataProviderID());
}

allnames

Get the names of all elements of the form, as an array.

Type Array

Sample

for (var i=0; i<elements.allnames.length; i++)
{
	var name = elements.allnames[i];
	var elem = elements[name];
	application.output(name + ": " + elem.getDataProviderID());
}

length

Get the number of elements of the form.

Type Number

Sample

for (var i=0; i<elements.length; i++)
{
	var elem = elements[i];
	application.output(elem.getName() + ": " + elem.getDataProviderID());
}

Last updated