JavaScript » Objects » Textarea

A Textarea object provides a multi-line field in which the user can enter data and is created with every instance of an HTML <TEXTAREA> tag on a form. These objects are then stored in the elements array of the parent form and accessed using either the name defined within the HTML tag or an integer (with '0' being the first element defined, in source order, in the specified form).



Syntax: Object.constructor

This specifies a function to create an object's property and is inherited by all objects from their prototype.


Syntax: object.defaultValue[ = "newdefaultvalue"]

This property sets or returns a string indicating the initial value of the Textarea object. The value of this property initially reflects the value between the start and end <TEXTAREA> tags. Use of the defaultValue property, which can be done at any time, will override the original value.


Syntax: textarea.form

This property returns a reference to the Textarea object's parent Form.


This property sets or returns the value of the Textarea object's name attribute.


Syntax: = value

This allows the addition of properties and methods to any object.


Syntax: object.type

Every element on a form has an associated type property. In the case of a Textarea object, the value of this property is always "textarea".


Syntax: object.value

This property sets or returns the Textarea object's value attribute. This is the text that is actually displayed in the Textarea and can be set at any time with any changes being immediately displayed.



Syntax: object.blur( )

This method removes the focus from the specified Textarea object.


Syntax: Object.eval(string)

The eval method is deprecated as a method of Object, but is still used as a high level function. It evaluates a string of JavaScript in the context of an object.


Syntax: object.focus( )

This method gives focus to the specified Textarea object.


Syntax: object.handleEvent(event)

This method calls the handler for the specified event.


Syntax: )

This method is used to select and highlight all or a portion of a text in a Textarea element. Used in conjunction with the focus method, this makes it easy to prompt the user for input and places the cursor in the correct place.


Syntax: Object.toSource()

The toSource method returns a literal representing the source code of an object. This can then be used to create a new object.


Syntax: Object.toString()

The toString method returns a string representing a specified object.


Syntax: Object.unwatch(property)

This method removes a watchpoint set for an object and property name with the watch method.


Syntax: Object.valueOf()

This method returns a primitive value for a specified object.


Syntax:, handlerfunction)

This method adds a watchpoint to a property of the object.

See Also: