# Javascript: FormFieldCollection.getItem Method

> Gets the form field at the current text input position or the form field with the specified id.

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 28.0
- **Path:** DS Server > Reference > JavaScript API > Javascript: FormFieldCollection.getItem Method
- **469 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/formfieldcollection/getitem-method/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/formfieldcollection/getitem-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/formfieldcollection/getitem-method/llms-full.txt

---

### Description

Gets the form field at the current text input position or the form field with the specified id.

### Syntax

```javascript
<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.

```javascript
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);
```

---

## Nearby

- **Previous:** [Javascript: FormFieldCollection.addTextFormField Method](https://docs.textcontrol.com/ds-server/reference/javascript/formfieldcollection/addtextformfield-method/llms-full.txt)
- **Next:** [Javascript: FormFieldCollection.remove Method](https://docs.textcontrol.com/ds-server/reference/javascript/formfieldcollection/remove-method/llms-full.txt)
