Skip to main content
Inspiring
February 23, 2009
Answered

Formatting text in a cell (word Wrap)

  • February 23, 2009
  • 1 reply
  • 960 views
Here is the problem in a nutshell...

I use the following table to enter a text entry into a field called "Techtext" in a Access database, data type "Memo".

<table width="690" border="1" cellspacing="1" cellpadding="3">
<tr>
<td width="21"> </td>
<td width="20"> </td>
<td width="22"> </td>
<td width="588"><strong>Text Entry </strong> </td>
</tr>
<tr>
<td height="189"><label>
<input name="hiddenField_User" type="hidden" id="hiddenField_User" value="<CFOUTPUT>#Session.MM_Username#</CFOUTPUT>" />
</label></td>
<td><label>
<input name="hiddenField_date" type="hidden" id="hiddenField_date" value="<CFOUTPUT>#DateFormat(Now(), "mm/dd/yyyy")#</CFOUTPUT>" />
</label></td>
<td><label>
<input name="hiddenField_pn" type="hidden" id="hiddenField_pn" value="<CFOUTPUT>#URLDecode (URL.Number)#</CFOUTPUT>" />
</label></td>
<td><label>
<textarea name="TechText" cols="85" rows="25" wrap="physical" id="TechText"></textarea>
</label></td>
</tr>
</table>


I am trying to display this data (and others) in a table. The Last table row is for addendum text display.
It should display the value of "Texttext" in the cell of this table. The problem is that the original data may not contain a carriage return, so the data just bleeds right off screen. Here is the code:

<table width="692" border="1" cellspacing="1" cellpadding="3">
<cfoutput query="Support">
<cfif Support.currentrow mod 1 eq 1>
<tr><tr><td> </td>
</cfif>
<td width="136"><strong>Addendum Date: </strong></td>
<td width="535">#Support.Date#</td>
</tr>
<tr>
<td><strong>Addendum By: </strong></td>
<td>#Support.User_Name#</td>
</tr>
<tr>
<td><strong>Addendum Text:</strong> </td>
<td width="85" align="left"><div align="left"><span class="style2">#Support.TechText#</span></div></td>
<tr>
<td><strong> </strong></td>
<td> </td>
<cfif Support.currentrow mod 1 eq 0>
</tr>
</cfif>
</cfoutput>
</table>


How can I get this data to display in 85 character lines (essentially adding a carriage return after every 85 character). I have searched the net, but have found no solution. You can see the resulting table here: http://devo.dns2go.com/info.cfm?PartNumber=AH058AA

Thank You in advance !

Eric
    This topic has been closed for replies.
    Correct answer Eric_Dahlenburg
    Thank You to Avatar for answering my question (Yes, I am an idiot !)
    You werr correct. My page was functioning correctly, I was just using bad test data.

    Also, thanks to Kapitaine for the alternate solution.

    Best Regards,

    Eric

    1 reply

    Participating Frequently
    February 23, 2009
    The only reason that the text keeps going on-and-on in one line is simply because there are no spaces in that "AddendumText" value. No single word is that long. If you actually put some real world dummy text you'll see that it will wrap correctly.
    February 24, 2009
    This is the normal behaviour of text on the web. If there are no carriage returns or space in the text it will just go over one line, on and on and on. It will do that on these very forums too.

    If you want a way of getting around it for formatting purposes, I guess you could use the len() function and some clever logic to insert a break or space at a given point.

    Mikey.
    Eric_DahlenburgAuthorCorrect answer
    Inspiring
    February 25, 2009
    Thank You to Avatar for answering my question (Yes, I am an idiot !)
    You werr correct. My page was functioning correctly, I was just using bad test data.

    Also, thanks to Kapitaine for the alternate solution.

    Best Regards,

    Eric