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?

4 of 15 people (27%) answered Yes
Recently 3 of 10 people (30%) answered Yes

Entry

How do I get width of TEXTAREA without forcing an inline or CSS WIDTH attribute?

Jun 2nd, 2005 06:13
Sebastian Pfistershammer, jsWalter,


With IE6 you can use
  document.forms[0].myTextarea.clientWidth and
  document.forms[0].myTextarea.clientHeight 
as initial values and 
  document.forms[0].myTextarea.scrollWidth or
  document.forms[0].myTextarea.scrollHeight 
when more text has been entered (which value changes depends 
on "wrap=..."). 
These values are also useful if you want to limit the number of lines 
and not only the number of characters of your textarea.
example:  
   if (document.forms[0].myTextarea.scrollHeight > document.forms
[0].myTextarea.clientHeight)
{
  alert("to much lines");
}