Ask a Jedi: Help in preserving user input
A reader asks:
I want to create a discussion board where I can retain the carriage returns that my users have entered - how can I pull their entries from the Database and retain the carriage returns without using the <pre> tags?
Out of the box, ColdFusion provides us with a paragraphFormat() function. This will correctly format blocks of text in paragraphs, inserting a P tag at blank lines. However, it won't correctly notice simple line breaks, like in an address. You can get around this by using a user-defined function like paragraphFormat2, written by Ben Forta. This UDF simply looks out for line breaks and inserts a BR tag. I use this on my Galleon ColdFusion forums.
Comments
One way to fix this is to install or include and online editor like khtml or fckeditor.
# Posted By Chris Bunting
| 1/30/06 7:29 PM
# Posted By Joe Lencioni
| 1/30/06 7:39 PM

Unfortunately, it's not perfect yet because I haven't had the time to properly test it, but it seems to be performing quite well so far.