sfGetText

Returns the text shown on a form control.

This function returns the text that is displayed on the form control that may not always be the value. In some controls like Selectbox, the text displayed is different than the value. If you intend to fetch the value of a field, use sfGetValue instead.

Syntax

sfGetText(id, index)

Parameters

Name

Type

Mandatory

Description

Name

Type

Mandatory

Description

id

string

yes

Control id of the form control.

index

number

no

Index of the form control. Applicable only if the control is present inside a group control.

The index is a zero-based index.

Applies to

Control type

Applicable

Remarks/Exceptions

Control type

Applicable

Remarks/Exceptions

Input controls

Yes

Applies to Checkbox, Multiple choice, Radio, Selectbox only.

Layout controls

No

 

Behaviour controls

No

 

Static information controls

No

 

Value returned by the function differs with the form control. See values returned by form controls.

Usage examples

Let us assume a form contains a multiple choice field Locations. The text of the selected items can be obtained using,

sfGetText('control_locations')

returns the location name, e.g. Netherlands. If more than one location is selected, it returns a comma separated list of location names, e.g. Netherlands,Belgium.

Return value formats

The function returns value in different formats depending on the form control.

Form control

Format

Remarks

Form control

Format

Remarks

Checkbox

Set 0: 0 or 1
Set 1: OK
Set 2: OK or NOK
Set 3: OK or NOK or NA
Set 4: OK or NOK or NA

Returns the selected option (depending upon the set used)

Multiple choice

 

Returns the text displayed for the selected dataset item

When multiple items are selected, it returns a comma separated list of text.

Radio

 

Returns the text displayed for the selected dataset item

Selectbox

 

Returns the text displayed for the selected dataset item