Javascript Form How to - Get value property from TextArea








Question

We would like to know how to get value property from TextArea.

Answer


<!--from w  w w . j  av a2  s.co m-->
<html>
<head>
    <script language="JavaScript">
    function resetText(){
      document.myForm.myTextArea.value = document.myForm.myTextArea.defaultValue;
    }
    </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="Reset" name="myButton" onClick='resetText()'>
    </form>
</body>
</html>

The code above is rendered as follows: