Returns HTML escaped string enclosed in <PRE>
and </PRE>
tags. All carriage returns are removed from string, and all special characters (> < " &) are escaped.
See also HTMLEditFormat.
HTMLCodeFormat(string [, version ])
String being HTML escaped and preformatted.
The specific HTML version to use in replacing special characters with their entity references. Valid entries are:
-1
-- The latest implementation of HTML2.0
-- For HTML 2.0 (Default)3.2
-- For HTML 3.2<HTML> <HEAD> <TITLE>HTMLCodeFormat</TITLE> </HEAD <H3>HTMLCodeFormat</H3> <BODY> <P>Often HTMLCodeFormat and HTMLEditFormat are used so that you can store textbox information in the database in HTML form. Here is an example that uses HTMLEditFormat to edit descriptive information found within the CFExpress database. Because you may not want to change the database, the CFQUERY statement that inserts the values into the database is commented out. </P> <CFIF IsDefined("Form.gogo")> <!---------------------------------------------------------------------- <CFQUERY NAME="PostMessage" DATASOURCE="CFExpress"> INSERT INTO Messages(employee_id,thread_id,subject,posted,message) VALUES('#form.employee_id_float#','#form.thread_id_float#', '#HTMLCodeFormat(Form.Subject)#',Now(),'#HTMLCodeFormat(Form.Message)#') </CFQUERY> -----------------------------------------------------------------------> <CFQUERY NAME="GetMessages" DATASOURCE="CFExpress"> SELECT subject, posted, employee_id, thread_id From Messages </CFQUERY> <H2>New Messages</H2> <table cellspacing="2" cellpadding="2" border="0"> <tr> <th>Employee ID</th> <th>Thread ID</th> <th>Subject</th> <th>Posted</th> </tr> <CFOUTPUT query="GetMessages"> <tr> <td>#employee_id#</td> <td>#thread_id#</td> <td>#subject#</td> <td>#posted#</td> </tr> </CFOUTPUT> </table> </CFIF> <CFOUTPUT> <FORM ACTION="htmlcodeformat.cfm" METHOD="POST"> <!---------------------------------------------------------------------- To simplify this example, set employee_id to represent a new employee to join the group, set thread_id to indicate a new thread, and pass these values as hidden form values. -----------------------------------------------------------------------> <CFQUERY NAME="GetIDs" DATASOURCE="CFExpress"> SELECT employee_id, thread_id From Messages </CFQUERY> <CFLOOP QUERY="GetIDs"> <CFSET employee_id = employee_id +1> <CFSET thread_id = thread_id +1> </CFLOOP> <INPUT TYPE="hidden" NAME="employee_id_float" VALUE="#employee_id#"> <INPUT TYPE="hidden" NAME="thread_id_float" VALUE="#thread_id#"> <TABLE> <TR> <TD><B>Subject:</B></FONT></TD> <TD><INPUT TYPE="text" NAME="Subject" SIZE=35 VALUE=""></FONT></TD> </TR> <TR> <TD COLSPAN=2><B>Message</B><BR> <TEXTAREA NAME="Message" COLS=50 ROWS=10 WRAP="VIRTUAL"></TEXTAREA> </TD> </TR> </TABLE> <INPUT TYPE="submit" NAME="gogo" VALUE="Post Message"> </FORM> </cfoutput> </BODY> </HTML>