Web site translator - 585Chapter 25 .Text-Related Form Objects Carriage returns inside

585Chapter 25 .Text-Related Form Objects Carriage returns inside textareas The three classes of operating systems supported by Netscape Navigator Windows, Macintosh, and UNIX do not agree about what constitutes a carriage return character in a text string. This discrepancy carries over to the TEXTAREA object and its contents on these platforms. After a user enters text and uses Enter/Return on the keyboard, one or more unseen characters are inserted into the string. In the parlance of JavaScript s literal string characters, the carriage return consists of some combination of the new line (n) and return (r) character. The following table shows the characters inserted into the string for each operating system category. Operating System Character String Windows rn Macintosh r Unix n This tidbit is valuable if you need to remove carriage returns from a textarea for processing in a CGI or local script. The problem is that you obviously need to per form platform-specific operations on each. For the situation in which you must pre serve the carriage return locations, but your server-side database cannot accept the carriage return values, I suggest you use the string.escape()method to URL- encode the string. The return character is converted to %0Dand the newline charac ter is converted to %0A. Of course these characters occupy extra character spaces in your database, so these additions must be accounted for in your database design. As far as writing carriage returns into textareas, the situation is a bit easier. From NN3 and IE4 onward, if you specify any one of the combinations in the preceding table, all platforms know how to automatically convert the data to the form native to the operating system. Therefore, you can set the value of a TEXTAREA object to 1rn2rn3 in all platforms, and a columnar list of the numbers 1, 2, and 3 will appear in those fields. Or, if you URL-encoded the text for saving to a database, you can unescape that character string before setting the textarea value, and no matter what platform the visitor has, the carriage returns are rendered correctly. Upon reading those values again by script, you can see that the carriage returns are in the form of the platform (shown in the previous table). Properties cols rows Value: Integer Read/Write NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5 Compatibility . . TEXTAREA.cols
Go visit our java server pages services for a reliable, lowcost webhost to satisfy all your needs.

Leave a Reply