[Chapter 21] Reference: Element.select()
Author: David Flanagan
Date: Fri Aug 29 11:15:39 1997

#

| Chapter 21 JavaScript Reference |

# Element.select() Method

## Name

Element.select() Method---select the text in form element

## Availability

Navigator 2.0, Internet Explorer 3.0

## Synopsis

    element.select()

### Arguments

none

### Returns

nothing

## Description

The `select()` method selects the text displayed in a Text, Textarea, Password, or FileUpload element. The effects of selecting text may vary from platform to platform, but typically invoking this method produces the same effect as if the user had dragged the mouse across all the text in the specified Text object. On most platforms, this produces the following effects:

- The text is highlighted, often displayed with colors reversed.

- If the text remains selected the next time the user types a character, then the selected text will be deleted and replaced with the newly typed character.

- The text becomes available for cut-and-paste.

The user can usually deselect text by clicking in the Text object or by moving the cursor. Once deselected, the user can add and delete individual characters without replacing the entire text value.

## Usage

Selecting a string in a Text object like this can be useful when you want to allow the user to accept the string as it is or to replace it entirely and enter a new value from scratch.

## Bugs

On Unix platforms in Navigator 2.0 and 3.0, the `select()` method only works for the Text element, and not for the Textarea, Password or FileUpload elements.

## See Also

"Element"

Element.options[] |  | Element.selectedIndex