Mega Code Archive

 
Categories / JavaScript Tutorial / Form
 

Textarea

Instances are created by the browser when it encounters an HTML tag. In the JavaScript object hierarchy, the Textarea object is located at window.document.Form.Textarea. Event Handlers/Methods/PropertiesDescription onBlurCalled when the text area loses the focus. onChangeCalled when the text area loses the focus and has had its value modified. onFocusCalled when the text area receives the focus. onKeyDownCalled when a key is pressed down. This occurs before an onKeyPress event handler is triggered. onKeyPressCalled when a key is pressed down immediately after an onKeyDown event handler is triggered. onKeyUpCalled when a key is released. onSelectCalled when a user selects some of the text within the text area. blur()Removes the focus from the text area. focus()Gives the focus to the text area. handleEvent()Invokes the handler for the event specified. select()Selects the text in the text area. defaultValueReturns the value of this text area defined between the beginning and ending tags. Note that this property is not supported by the Opera browsers. formReturns the entire form the text area is in. nameReturns the name of this text area specified by the NAME attribute. typeReturns the type of this text area. Note that this is always textarea. valueReturns the value that is actually displayed in the text area. <html>     <head>     <script language="JavaScript">     <!--     function openWin(){       var myInstance = document.myForm.myTextArea;       var myWin = open("", "","width=450,height=200");       myWin.document.write("The defaultValue is: " + myInstance.defaultValue + "<br>");       myWin.document.write("The name is: " + myInstance.name + "<br>");       myWin.document.write("The type is: " + myInstance.type + "<br>");       myWin.document.write("The value is: " + myInstance.value + "<br>");       myWin.document.write(myInstance.form.myButton.value);       myWin.document.close();     }     -->     </script>     </head>     <body>     <form name="myForm">       <textarea name="myTextArea" rows=6 cols=50>       Here is some text in my text area.       </textarea>       <input type=BUTTON value="Click to Process" name="myButton" onClick="openWin()">     </form>     </body>     </html>