faqts : Computers : Programming : Languages : JavaScript : Forms : TextAreas/TextFields

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

30 of 44 people (68%) answered Yes
Recently 9 of 10 people (90%) answered Yes

Entry

How can I resize the textarea to be 100% of it's container (in Nestcape, IE not a problem)

Sep 13th, 2000 08:18
Amir Zucker,


Well, since I found an answer, I might as well share with the other 
kids.  This is not a perfect answer. 
Basically what I did is take my entire width (innerWidth) and divide it 
by column width (8.35 by tests).
That gave me the number of columns I want.  You have to make sure the 
page is reloaded if you want this to work with resize as well.
The onKeyDown part is a little bonus - will allow you to submit when 
user pressed enter in the textarea.  You can take it off if you don't 
need it.  isEnter should process the keypress and return true if you 
want the keypress to be accepted.

<form action="" name="FORM1" id="FORM1">
<script language="JavaScript">
document.writeln('<textarea cols="' + innerWidth / 8.35 + 
'" rows="2" name="textarea1" id="textarea1" wrap="soft" id="textarea1" 
onKeyDown="return isEnter(event)"></textarea>');
</script>
</form>