I have a textarea with 200px of height, but when I pass that 200px with text I want to have the textarea expanded instead of keeping the 200px of height with a scroll bar.>
Here's a simple, pure php and html, solution, without need for js, to make the textarea fit to size.
HTML:
= $rows) {
$rows = $minrows;
}
// Return the number of rows
return $rows;
}
?>
`And this one is even shorter and better:
function linecount($text, $cols, $minrows=1) {
if ($text <= '') {return $minrows;}
$text = wordwrap($text, $cols, PHP_EOL);
$rows = substr_count( $text, PHP_EOL )+1;
if ($minrows >= $rows) {$rows = $minrows;}
return $rows;
}
?>