Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

WYSIWYG Test

New Here ,
Dec 16, 2010 Dec 16, 2010

Hi everyone,

I have multiple forms with textarea fields on my Web site. Most of the time, the text entered in one of these textareas is saved in a db or emailed with cfmail. Is there a way to preserve paragraph formatting when the text is saved/emailed/etc.? For example, if a user is typing in the textarea and hits return a few times to create a new paragraph, is there a way to transfer those returns to the database/email? If I output the text they entered either on a Web page or in an email, CF just outputs it as a long text string with no breaks.

I've ready about editors that can be downloaded and installed on the server that will help control other text formatting, but at this point I'm not interested in getting that advanced. Any help or direction is greatly appreciated!

536
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Contributor , Dec 16, 2010 Dec 16, 2010

Might also want to look into paragraphFormat() built in function or http://cflib.org/udf/paragraphFormat2

Translate
Valorous Hero ,
Dec 16, 2010 Dec 16, 2010

The returns are preserved.

straffenp wrote:

CF just outputs it as a long text string with no breaks.

No it does not.  Look at the source code in your browser where you have output one of those stored text strings.  There are all the returns that where typed into the input.

Your problem is that these are ASCII (or other encoding) CHARACTER returns and the HTML standard specifies that browsers should IGNORE all such white space characters.

The fastest and simplest solution:

Output the strings inside an HTML <pre>...</pre> block that the HTML standard says will tell the browser to NOT ignore white space characters.

But many may not like the way <pre> block text looks.  It can be styled with CSS so that may be solvable.

But if that is not a good enough solution, you will need something that will turn the character encoding returns into HTML <br/> and|or <p>...</p> tags.  That is what many of those text editors will try to do for you with greater and lesser success.

ColdFusion comes with the FCKeditor built in.  The documentation has plenty of documentation on how to  use it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 16, 2010 Dec 16, 2010

Might also want to look into paragraphFormat() built in function or http://cflib.org/udf/paragraphFormat2

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 16, 2010 Dec 16, 2010
LATEST

Thank to both of your for your replies. For now, because it worked quickly and because I ran into issues with CSS, I'll use cfsilence's solution.  It's exactly what I had in mind. Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources