Raymond Camden's Blog Rss

Ask a Jedi: Help in preserving user input

3

Posted in ColdFusion | Posted on 01-30-2006 | 1,905 views

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

[Add Comment] [Subscribe to Comments]

I was recently struggling with this same issue and found the solutions floating around the Inetenet to be less than perfect. So, I came up with a new <a href="http://www.gustavus.edu/oncampus/gts/webservices/a... function</a> that you might find helpful.

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.
Hello,
One way to fix this is to install or include and online editor like khtml or fckeditor.
Yes, I have used FCKEditor in some projects and it is very slick. Another good one is TinyMCE.