Adaptive word wrap
I found this word wrap function on the net and it works great but what I want to do is modify it so that it puts each line inside a <input type="text" value="????"> box.
<----------- CODE ----------->
Dim strTextPreWrap, strTextPostWrap, intWrapPosition
strTextPreWrap = "The quick brown fox jumps over the lazy dog. " _
& "The quick brown fox jumps over the lazy dog again. " _
& "The quick brown fox jumps over the lazy dog one more time."
intWrapPosition = 45
strTextPostWrap = WordWrap(strTextPreWrap, intWrapPosition)
Function WordWrap(strTextToBeWrapped, intMaxLineLength)
Dim strWrappedText
Dim intLengthOfInput
Dim intCurrentPosition
Dim intCurrentLineStart
Dim intPositionOfLastSpace
intLengthOfInput = Len(strTextToBeWrapped)
intCurrentPosition = 1
intCurrentLineStart = 1
rsLineCounter = 1
DO WHILE intCurrentPosition < intLengthOfInput
If Mid(strTextToBeWrapped, intCurrentPosition, 1) = " " THEN
intPositionOfLastSpace = intCurrentPosition
END IF
IF intCurrentPosition = intCurrentLineStart + intMaxLineLength THEN
rsLineCounter = rsLineCounter + 1
strWrappedText = strWrappedText _
& Trim(Mid(strTextToBeWrapped, intcurrentLineStart, _
intPositionOfLastSpace - intCurrentLineStart + 1)) _
& vbCrLf
'strWrappedText2 = "<input type='text' name='item" & rsCount & "desc' value='" & strWrappedText & "' size='53' class='f5' onKeyPress='doFunction1(this);'>"
intCurrentLineStart = intPositionOfLastSpace + 1
DO WHILE MID(strTextToBeWrapped, intCurrentLineStart, 1) = " "
intCurrentLineStart = intCurrentLineStart + 1
LOOP
END IF
intCurrentPosition = intCurrentPosition + 1
LOOP
strWrappedText = strWrappedText & Trim(Mid(strTextToBeWrapped, intcurrentLineStart)) & vbCrLf
WordWrap = strWrappedText
response.write "Number of Lines: <b>" & rslinecounter & "</b><br>"
End Function
Function AddBrToCrLf(strInput)
AddBrToCrLf = Replace(strInput, vbCrLf, "<br />" & vbCrLf)
End Function
%>
<%=AddBrToCrLf(strTextPostWrap) %><br>
<----------- END CODE ----------->
At the moment the code puts CRLF in at the correct positions and then replaces them with <br>. How can I make it output the lines in an <input> box.
Any ideas greatly received.
Many thanks,
Paul Jacobs
|