Click to See Complete Forum and Search --> : TEXTAREA


mosman
July 27th, 2000, 01:57 PM
Hello Everyone;
I am writing an ASP file with TEXTAREA control, what I am trying to do, is to have fixed width for the textarea control and variable height depending on the number of text lines in the control. i.e. I don't want to scroll to see all the text in the TEXTAREA control.

Johnny101
July 27th, 2000, 03:13 PM
then before you supply the textarea's rows property, yuo can determine this by dividing the length of the text to be entered by the number of cols to be used in the text box and add one, or round up essentially. something like this might work:

dim icol
dim sreturn

'stext is the actual text that is to be placed in the textarea box. i assume you are hardcoding the
'width of the textarea, for example, lets say 60

icol = len(stext)/60
'we need the whole number value, so just take the left of the result up until the decimal
'since this number is rounded down, we need to increment it by one, so that it simulates
'a rounding up
icol = left((icol, instr(1,icol,".")-1) + 1

sreturn = "<textarea cols=60 rows=" & icol & ">" & stext & "</textarea>"

response.write sreturn




hope this helps,

John

John Pirkey
MCSD
http://www.ShallowWaterSystems.com
http://www.stlvbug.org

mosman
July 27th, 2000, 03:40 PM
This is not going to work, because the text wrap is turned on, so the line could contain 60 charactors of may be 10; since we have to consider the carriage return and long words toward the end of the line

Johnny101
July 27th, 2000, 04:20 PM
for the carriage returns, do a search in the string for "vbCrLf" and add the number that comes back to the number of rows. for the long words that are to be wrapped - just add a larger number on the end. without parsing each resulting line of text, this is as good as your going to get.


dim icol
dim sreturn
dim icount

'stext is the actual text that is to be placed in the textarea box. i assume you are hardcoding the
'width of the textarea, for example, lets say 60

icol = len(stext)/60
'we need the whole number value, so just take the left of the result up until the decimal
'since this number is rounded down, we need to increment it by one, so that it simulates
'a rounding up
icol = left((icol, instr(1,icol,".")-1) + 1

'add the number of carriage returns in the text. and a little extra for long words at end of line
icount = UBound(split(stext,vbcrlf))
icol = icol + icount + 10

sreturn = "<textarea cols=60 rows=" & icol & ">" & stext & "</textarea>"

response.write sreturn





that's as far as i'm going with this - and you're welcome.

John

John Pirkey
MCSD
http://www.ShallowWaterSystems.com
http://www.stlvbug.org

mosman
July 28th, 2000, 07:51 AM
I will try that.
Thank you very much.