• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Using Text Areas

The big difference between text areas and the text controls we’ve already seen in this chapter is that text areas are two-dimensional, not one-dimensional, and can display multiple lines of text. Here’s an example that does exactly that when you click a button. In this case, the text displayed in the text area is Hello\nfrom\nJavaScript!, where \n is the JavaScript newline character (corresponding to ASCII/Unicode code 10), which causes the text to jump to the next line:

(Listing 13-06.html on the web site)

<HTML> 
    <HEAD> 
        <TITLE>Using the &lt;TEXTAREA&gt; Element</TITLE> 
        <SCRIPT LANGUAGE="JavaScript"> 
            <!--
            function DisplayMessage()
					{
					document.form1.textarea1.value = "Hello\nfrom\nJavaScript!"
					} 
            //--> 
        </SCRIPT> 
    </HEAD> 

    <BODY> 
        <H1>Using the &lt;TEXTAREA&gt; Element</H1> 
        <FORM NAME="form1">
					<TEXTAREA NAME="textarea1" COLS="30" ROWS="10"></TEXTAREA>
					<BR>
					<INPUT TYPE="BUTTON" Value = "Display Message" ONCLICK="DisplayMessage()">
					</FORM> 
    </BODY> 
</HTML> 

					  


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint