Question

How can I add a CRLF into a Textarea using Coldfusion 7 code?

I've tried every way that I can think of and every way that I've found. Nothing is working for IE6. In Chrome and IE8 pretty much everything I try works fine... However, this app has to run in IE6.

The below code is how I'm building my string for the textarea.

<cfset qResults = "">
<cfif myQuery.RecordCount GT 0>
    <cfloop query="myQuery">
        <cfset qResults="#qResults#" 
                          & "#qfield1# #qfield2# #qfield3# &nbsp;|__|&nbsp; " 
                          & Chr(13) & Chr(10)>
    </cfloop>
<cfelse>

As you can see, I've just gone to separating the different query returns by an ugly |__| since I can't get anything else to work.

I've also tried just the CR or just the LF and I've also tried html breaks.


@Dan Roberts

Well, that could be the issue. This is pulling data in dynamically through javascript. The user clicks a textbox, selects from a dropdown, and the rest of the fields on the form are populated with the relevant information. The code above, actually sits on a popDB.cfm page, it's called by

$.post("popDB.cfm", {id: thisValue}, function(data) {
        var dataArr = data.split(',');

Later on in the function, the actual field is populated by:

$('#qResultsID' + iter).html(dataArr[16]); 

I have tried all these methods separately as well.

Was it helpful?

Solution

chr(10) should work for you if there are no other issues

<cfset str = "" />
<cfloop list="item1,item2,item3" index="listitem">
    <cfset str &= listitem & chr(10) />
</cfloop>
<cfoutput><textarea rows="10" cols="10">#str#</textarea></cfoutput>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top