# Javascript: TextFieldCollection.getItem Method

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

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

---

### Description

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

### Syntax

```javascript
<void> TextFieldCollection.getItem(<RequestTextFieldCallback> 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 text field with the specified identifier does not exist. |

### Examples

The following example demonstrates `TextFieldCollection.getItem` in a practical document-editing workflow. It gets the text field at the current text input position or the text 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 textFields = mainText.textFields;
    textFields.getItem(
        function(field) {
            if (!field) {
                console.warn("No text field was returned.");
                return;
            }
            
            console.log("get item result:", field);
        },
        onTxError,
        25
    );
}, onTxError);
```

---

## Nearby

- **Previous:** [Javascript: TextFieldCollection.clear Method](https://docs.textcontrol.com/ds-server/reference/javascript/textfieldcollection/clear-method/llms-full.txt)
- **Next:** [Javascript: TextFieldCollection.remove Method](https://docs.textcontrol.com/ds-server/reference/javascript/textfieldcollection/remove-method/llms-full.txt)
