|
|||||||
New to SitePoint Forums? Register here for free!
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
SitePoint Evangelist
![]() ![]() ![]() ![]() Join Date: Dec 2005
Posts: 595
|
Textarea collapses?!?
I have this expandable textarea which works fine except... Whe a user starts typing it collapses inti 1 row and from there expands as it should even though I have set the rows to 4? How do I get passed this?
Code:
<script>
var maxrows=50;
function doResize(box) {
var txt=box.value;
var cols=box.cols;
var arrtxt=txt.split('\n');
var rows=arrtxt.length;
for (i=0;i<arrtxt.length;i++)
rows+=parseInt(arrtxt[i].length/cols);
if (rows>box.maxrows)
box.rows=box.maxrows;
else
box.rows=rows;
}
</script>
<textarea class="expandtextarea2" id="box1" name="box1" rows=4 cols="56" onkeyup="doResize(this)" onkeydown="doResize(this)">
|
|
|
|
|
|
#2 |
|
SitePoint Enthusiast
![]() Join Date: Nov 2008
Location: Thailand
Posts: 74
|
This seems to do the trick
change HTML Code:
var rows=arrtxt.length; HTML Code:
var rows=(arrtxt.length<4)?4:arrtxt.length; |
|
|
|
|
|
#3 |
|
SitePoint Evangelist
![]() ![]() ![]() ![]() Join Date: Dec 2005
Posts: 595
|
Thanks... Did the job :-)
|
|
|
|
![]() |
| Bookmarks |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
|
All times are GMT -7. The time now is 04:55.








Linear Mode
