Formatting Techniques
Once you have query data in the form of a result set, you might want to massage it a bit before outputting it to the browser or to a file. ColdFusion provides several built-in functions for formatting a variety of datatypes. This section covers some of the more popular functions for formatting strings, HTML code, numbers, currency, dates, times, and Boolean values. For more information on all the functions covered in this section, see Appendix B.
Formatting Plain-Text Strings
ColdFusion
provides functions for formatting text strings:
ParagraphFormat( ), Ucase( ),
Lcase( ), JSStringFormat( ),
and XMLFormat( ). Each function is covered in the
sections that follow.
Using ParagraphFormat
ParagraphFormat( )
takes a string and formats it so that single newline characters are
replaced with a space, and double newline characters are replaced
with HTML <P> tags. This function is most
often used to display data that has been entered into a
Textarea HTML form field. The following example
shows how the ParagraphFormat( ) function handles
single and double newline characters:
<CFSET MyText="This is my block of text. It has both single newline characters in it like this paragraph, and double newline characters like in the next paragraph. This is the paragraph with the double newline characters."> <FORM> <CFOUTPUT> <TEXTAREA COLS=50 ROWS=10 NAME="TheText" WRAP="virtual"> #ParagraphFormat(MyText)# </TEXTAREA> </CFOUTPUT> </FORM>
Changing case
You can change the case of ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access