On 12 Mar, 17:06, "Ivo" <n...@thank.youwrote:
Quote:
<gilbert.geo...@whoever.comtypedI am setting the width of a textarea using the style.width to ensure
Quote:
the textarea is exactly the right width.
>
Quote:
I want to set the height/rows of the textarea depending on it's
contents (so that it dynamically grows and shrinks as the contents
alter) however I can not see a way to calculate the required number of
rows (or height) for a given content string.
>
Quote:
If all the lines of content are shorter that than the width of the
area then it's simple but obviously this is not always the case, so I
have a function that splits the content into lines then each line into
>
<snip>
>
Instead of measuring the text, compare the offsetHeight and scrollHeight of
the textarea. If the scrollHeight is the larger, you know you need to
increase the area's size.
hth
ivohttp://4umi.com/web/javascript/
thanks for that, i now have far simpler code
text_area.style.height = text_area.scrollHeight + "px";
as i want to have the area fit the contents not just increase when it
grows (ie shrink when the contents decrease)
this works fine in IE but in FF it makes the text area grow with each
char added not every row.
any ideas why?