For example:
A user submits a form with a <textarea name="mytext" cols="35" rows="2"></textarea>
and presses ENTER within it. How would I replace the CR-LF with a <br />
?
CF has a function for this called ParagraphFormat():
<cfset form.userText = paragraphFormat(form.usertext)/>
From the help docs -
Replaces characters in a string:
<p>
)It may do more than you want in that it also looks for double line breaks and adds <p>
and </p>
tags.
Ben also has an enhanced version (a UDF) called paragraph2 that would be easy to modify to get the exact affect you want. Here's the link: