View comments | RSS feed

ParagraphFormat

Description

Replaces characters in a string:

Return value

A copy of the string, with characters converted.

Category

Display and formatting functions, String functions

Syntax

ParagraphFormat(string)

See also

StripCR

Parameters

Parameter Description
string
A string or a variable that contains one

Usage

This function is useful for displaying data entered in textarea fields.

Example

<h3>ParagraphFormat Example</h3>
<p>Enter text into this textarea, and see it returned as HTML.
<cfif IsDefined("FORM.myTextArea")>
  <p>Your text area, formatted
  <p><cfoutput>#ParagraphFormat(FORM.myTextArea)#</cfoutput>
</cfif>
<!--- use #Chr(10)##Chr(13)# to simulate a line feed/carriage
return combination; i.e, a return --->
<form action = "paragraphformat.cfm">
<textArea name = "MyTextArea" cols = "35" ROWS = 8>
This is sample text and you see how it scrolls
<cfoutput>#Chr(10)##Chr(13)#</cfoutput>
From one line 
<cfoutput>#Chr(10)##Chr(13)##Chr(10)##Chr(13)#</cfoutput>
to the next
</textArea>
<input type = "Submit" name = "Show me the HTML version">
</form>

ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6

Comments are no longer accepted for ColdFusion MX. ColdFusion 8 is the current version.

Comments


Th0r said on Aug 4, 2004 at 6:10 AM :
It would be nice to have proper syntax when using ParagraphFormat. i.e.: Closed p tags.
jrunrandy said on Aug 4, 2004 at 6:32 AM :
This example should use method="post" in the form tag.
Simon.Harper said on Sep 15, 2004 at 4:51 AM :
Could a single line feed to become a <br> ?
halL said on Sep 17, 2004 at 8:46 AM :
PragraphFormat does not include a way to convert single line feeds to <br> tags.
spindiggy said on Mar 24, 2006 at 10:26 AM :
Hello..

Create a new udf file called FormatIT.cfm - Include

<cfscript>
function FormatIT(string) {
return replace(string, Chr(10) & Chr(13),"<br />","ALL");
}
</cfscript>

Now, where ever you need to format text from a standard text area, use the following. Replace rs.pdesc with your query.content or whatever.

<cfoutput>#FormatIT(rs.pdesc)#</cfoutput>

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6/CFML_Reference/functions-pt248.htm