Preserving Input
In ColdFusion 5.0, a new attribute
called preservedata
was added to the
cfform
tag. Setting
preservedata
to Yes
causes
ColdFusion to retain and display data submitted from a
cfinput
, cftextinput
,
cfslider
, or cftree
control
when a form is submitted to itself or to another page with like-named
cfform
controls. The exact effect of the
preservedata
attribute depends on the type of form
control you use in your cfform
. For
cfinput
and cftextinput
controls, setting preservedata
to
Yes
allows you to display the data entered by the
user after the form has been submitted without any additional coding.
For cfslider
controls, the slider is set
automatically to the position from the previous form post. For
cftree
controls, the tree expands automatically to
the branch containing the previously selected item. For
preservedata
to work with a tree control, the
completepath
attribute of the
cftree
tag must be set to Yes
.
Example 10-26 shows how the
preservedata
attribute works with each type of
form control it is compatible with. Using
CGI.Script_Name
for the action
attribute of the cfform
tag causes the form to
post to itself, regardless of the filename you use to save the file.
Example 10-26. Using the preservedata attribute of cfform
<cfform action="#CGI.Script_Name#" name="MyForm" preservedata="Yes" enctype="application/x-www-form-urlencoded"> <table> <tr> <td>cfinput (text):</td> <td><cfinput type="text" name="teex" size="10" maxlength="10"></td> </tr> <tr> <td>cfinput (password):</td> ...
Get Programming ColdFusion MX, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.