We help IT Professionals succeed at work.

Resizing a textarea

TonySmith
TonySmith asked
on
Medium Priority
1,372 Views
Last Modified: 2008-03-17
What I'm trying to do is to resize a textarea HTML object when the browser window is resized.  The concept is so simple to do in Visual Basic, but how do you do this in JavaScript?
Comment
Watch Question

Commented:
Try relative values (directly in HTML):

<textarea style="width:50%;height=50%"></textarea>

and for javascript, you can access to style.width and style.height and change as you wish.

Commented:
if you need something more complicated you can try capturing the rize event of the window and doing the calculations there, something like:

<textarea id=myTextArea></textarea>



function window.onresize
{
  myTextArea.width=(document.body.width)/2-20;
  myTextArea.height= ...



}

Explore More ContentExplore courses, solutions, and other research materials related to this topic.