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 |
---|---|---|---|
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 |
---|---|---|
Yes | Applies to Checkbox, Multiple choice, Radio, Selectbox only. | |
No |
| |
No |
| |
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 |
---|---|---|
Set 0: 0 or 1 | Returns the selected option (depending upon the set used) | |
| Returns the text displayed for the selected dataset item When multiple items are selected, it returns a comma separated list of text. | |
| Returns the text displayed for the selected dataset item | |
| Returns the text displayed for the selected dataset item |