Javascript Form How to - Get type property from TextArea








Question

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

Answer


<html>
<head>
    <script language="JavaScript1.1">
    function getType(){<!--from w ww  . jav a 2 s.  c o  m-->
      console.log("The name of this text area is " + document.myForm.elements[0].type);
    }
    </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="Get Type" name="myButton" onClick='getType()'>
    </form>
</body>
</html>

The code above is rendered as follows: