Wrox Programmer Forums
|
ASP Pro Code Clinic As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Pro Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 17th, 2005, 05:03 PM
Authorized User
 
Join Date: Jun 2003
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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





Similar Threads
Thread Thread Starter Forum Replies Last Post
word wrap in listbox vjyrakesh C# 2005 1 May 22nd, 2008 09:39 AM
word wrap.... rupen CSS Cascading Style Sheets 2 January 24th, 2007 03:10 PM
IE6 word-wrap problem? beckfield XSLT 5 March 4th, 2005 02:59 PM
DataList does not do word wrap vinod_pawar1 General .NET 2 October 27th, 2004 11:00 PM
Wrap Up feature (like Word Mail Merge) jmurdock BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 June 28th, 2004 03:20 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.