|
|
 |
expandable textarea
stokh | Posted 9:15am 5. August 2002 Server Time |
Does anyone know how to have an expandable textarea. What I mean is having it start at 1 line and thats all it will show if thats all that is there, but if there is 8 lines in the next record it shows 8 and if 15 lines the next record it shows 15????
Thanks!
Stokh!
|
mp3cdman | Posted 12:24am 5. August 2002 Server Time |
Here you go girl...
specially written for you...since i've no job so nothing better to do....lol
<html> <head> <script> var maxrows=10; function doResize() { var txt=document.all.box1.value; var arrtxt=txt.split('\n'); if (arrtxt.length>maxrows) document.all.box1.rows=maxrows; else document.all.box1.rows=arrtxt.length; } </script> </head> <body> <textarea id="box1" name="box1" rows=1 cols=30 onkeyup="doResize();">Test</textarea> </body> </html>
mp3cdman ;-)
mp3cdman | Posted 12:26am 5. August 2002 Server Time |
ooops i never read your last post correctly
just fill the textarea with the correct data then call the doResize() in the onload event of the body tag
mp3cdman
mp3cdman | Posted 12:47am 5. August 2002 Server Time |
in fact if you are pulling the record from a database, say its called "record"
you'll be doing
<textarea name="box1" rows=1 cols=30><%=RS("record")%></textarea>
so just change this to
<% intMaxRows=10 arrRows=Split(RS("record"), vbCrLf) intRows=UBound(arrRows)+1 If intRows>intMaxRows Then intRows=intMaxRows %> <textarea name="box1" rows=<%=intRows%> cols=30><%=RS("record")%></textarea>
hey its another solution anyway
mp3cdman ;-)
stokh | Posted 7:39am 7. August 2002 Server Time |
Hey I am going to try this cause they said (the other programmers here) said there wasnt away to do this without JavaScript. So I will do this and let you know if it works.....
You are truly the MASTER! :)
stokh | Posted 8:59am 7. August 2002 Server Time |
Ok I assume that box1 is the name of the field so I would have to write the script to match every field that I want this to occur...man nothing can never be easy can it! :(
stokh | Posted 9:23am 7. August 2002 Server Time |
can you do it with a text box as well?
mp3cdman | Posted 10:18am 7. August 2002 Server Time |
hey stokh
i'm sure you can do it for textboxes to in fact gimme a half an hour and i'll try to write one which will work for whatever you use it on...
mp3cdman
the asp version will only set the size of the textare based on what comes from the database... it wont resize on the webpage dynamically unless you use Javascript or VBscript client side...
stokh | Posted 10:28am 7. August 2002 Server Time |
Yeah I got that, so then I need to use this var maxrows=10; function doResize(){ var txt=document.all.custLocation.value;var arrtxt=txt.split('\n'); if (arrtxt.length>maxrows) document.all.custLocation.rows=maxrows; else document.all.custLocation.rows=arrtxt.length;
for each field that I need it to grow on? Correct?
half hour is fine i will be here for another hour and then time to go home and no working at home today getting ready to go on vacation and kids have football camp starting this afternoon:)
I get 4 whole days in Santa Monica on the Ocean.....YIPPY
mp3cdman | Posted 10:34am 7. August 2002 Server Time |
hi again
try this
<html> <head> <script> var maxrows=10;
function doResize(box) { var txt=box.value; var arrtxt=txt.split('\n'); if (arrtxt.length>box.maxrows) box.rows=box.maxrows; else box.rows=arrtxt.length; } </script> </head> <body> <textarea id="box1" name="box1" rows=1 cols=30 onkeyup="doResize(this);" onkeydown="doResize(this);" maxrows=5>Test</textarea> <textarea id="box2" name="box2" rows=1 cols=30 onkeyup="doResize(this);" onkeydown="doResize(this);" maxrows=10>Test</textarea><br> <textarea id="box3" name="box3" rows=1 cols=30 onkeyup="doResize(this);" onkeydown="doResize(this);" maxrows=15>Test</textarea> <textarea id="box4" name="box4" rows=1 cols=30 onkeyup="doResize(this);" onkeydown="doResize(this);" maxrows=20>Test</textarea> </body> </html>
it allows you to put maxrows=x in each textare to determine how big the box can be...
mp3cdman
mp3cdman | Posted 10:35am 7. August 2002 Server Time |
well you have a good vacation and i hope this helps you out
mp3cdman
Show all replies to 'expandable textarea'
|
To post a message to this discussion you need to be
a Haneng.com member. If you already are a member please log in
if not register as a member here (free).
|
|
|
|
 |
|