Полезная информация

JavaScript: The Definitive Guide

Previous Chapter 21
JavaScript Reference

Textarea.value Property


Textarea.value Property---user input to the Textarea object


Navigator 2.0, Internet Explorer 3.0




value is a read/write string property of the Textarea object. The initial value of value is the same as the defaultValue property--the plain text (i.e., without any HTML tags) that appears between the <TEXTAREA> and </TEXTAREA> tags. When the user types characters into the Textarea object, the value property is updated to match the user's input. If you set the value property explicitly, the string you specify will be displayed in the Textarea object. This value property contains the string that is sent to the server when the form is submitted.


In Navigator 2.0, the Textarea object required the use of platform-specific newline characters or newline sequences. Thus, appending the "\n" character (newline character for Unix) to the value property of a Textarea object would not actually start a new line on Windows platforms (which use a sequence of "\r\n" to delimit lines), for example. In Navigator 3.0, this problem has been resolved--any newline character or sequence is automatically mapped to the correct platform-specific sequence.

To workaround the bug on Navigator 2.0 platforms, you'll need a variable that contains the platform-specific newline sequence. One easy way to obtain such a "newline" variable is to create your Textarea element with a default value which consists of a single blank line. Then you can copy the value property of this element; it will contain the newline sequence required on the current platform.

See Also


Previous Home Next
Textarea.type Book Index top

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell