Javascript: FormFieldCollection.getItem Method
Description
Gets the form field at the current text input position or the form field with the specified id.
Syntax
<void> FormFieldCollection.getItem(<RequestFormFieldCallback> callback, [<ErrorCallback> errorCallback], [<number> id])Parameters
| Parameter | Description |
|---|---|
| callback | The callback function that receives the requested value. |
| errorCallback | Optional. Is called when the operation failed with an error. |
| id | Optional. Specifies the text field's identifier set with the ID property. The method returns null if a form field with the specified identifier does not exist. |
Examples
The following example demonstrates FormFieldCollection.getItem in a practical document-editing workflow. It gets the form field at the current text input position or the form field with the specified id.
function onTxError(error) {
console.error("TX Text Control error:", error.msg);
error.handled = true;
}
TXTextControl.textParts.getMainText(function(mainText) {
const formFields = mainText.formFields;
formFields.getItem(
function(formField) {
if (!formField) {
console.warn("No form field was returned.");
return;
}
console.log("get item result:", formField);
},
onTxError,
25
);
}, onTxError);