HTMLEditFormat

Returns HTML escaped string. All carriage returns are removed from string, and all special characters (> < " &) are escaped.

See also HTMLCodeFormat.

Syntax

HTMLEditFormat(string [, version ])
string

String being HTML escaped.

version

The specific HTML version to use in replacing special characters with their entity references. Valid entries are:

Usage

By escaping all special characters, this function increases the length of the specified string. This can cause unpredictable results when performing certain string functions (Left, Right, and Mid, for example) against the expanded string.

Example

<HTML>
...
<BODY>

<H3>HTMLEditFormat</H3>

<P>Often HTMLCodeFormat and HTMLEditFormat are used so that you can edit 
information within a text box. 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#', 
'#HTMLEditFormat(Form.Subject)#',Now(),'#HTMLEditFormat(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="htmleditformat.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>