meems
04-24-2003, 07:59 PM
This is the JS code that I am using to expand a textarea.
But it only expands when the enter key is pressed.
Would like to know if there is a way to expand the textarea
dynamically, maybe onLoad?
Thanks
<script>
function adjustRows (textarea) {
if (document.all) {
while (textarea.scrollHeight > textarea.clientHeight)
textarea.rows++;
textarea.scrollTop = 0;
}
else if (textarea.rows) {
var lineBreaks = countLineBreaks(textarea.value);
var rows = parseInt(textarea.rows);
var wrap = textarea.getAttribute('wrap');
if (lineBreaks > rows)
textarea.rows = ++rows;
else if (wrap.toLowerCase() == 'soft' || wrap.toLowerCase() ==
'hard') {
while (textarea.rows * textarea.cols <= textarea.value.length) {
textarea.rows = ++rows;
}
}
}
}
</SCRIPT>
<td><pre><TEXTAREA class="combi" rows="4" cols=50 name="comment_text" wrap="yes" wrap="hard" ONKEYUP="adjustRows(this)">#getCmtStf.comment_text#</TEXTAREA></pre>
</td>
But it only expands when the enter key is pressed.
Would like to know if there is a way to expand the textarea
dynamically, maybe onLoad?
Thanks
<script>
function adjustRows (textarea) {
if (document.all) {
while (textarea.scrollHeight > textarea.clientHeight)
textarea.rows++;
textarea.scrollTop = 0;
}
else if (textarea.rows) {
var lineBreaks = countLineBreaks(textarea.value);
var rows = parseInt(textarea.rows);
var wrap = textarea.getAttribute('wrap');
if (lineBreaks > rows)
textarea.rows = ++rows;
else if (wrap.toLowerCase() == 'soft' || wrap.toLowerCase() ==
'hard') {
while (textarea.rows * textarea.cols <= textarea.value.length) {
textarea.rows = ++rows;
}
}
}
}
</SCRIPT>
<td><pre><TEXTAREA class="combi" rows="4" cols=50 name="comment_text" wrap="yes" wrap="hard" ONKEYUP="adjustRows(this)">#getCmtStf.comment_text#</TEXTAREA></pre>
</td>