Javascript Form How to - Set Textarea rows and columns








Question

We would like to know how to set Textarea rows and columns.

Answer


   <!--from w w  w.j  av  a2  s.co  m-->
    
<html>
<body>
<textarea id="myText" rows="3" cols="15">
</textarea>
<br>
<button onclick="myText.cols=100;">Set width of Textarea to 100</button>
<button onclick="myText.rows=20;">Set height of Textarea to 20</button>
</body>
</html>

The code above is rendered as follows: