System information

106 Chapter 10: Lesson 7: Validating Data to Enforce Business Rules
<TR>
<TD valign="top">Photo File Name</TD>
<TD><INPUT maxLength=50 size=50 name=photo></TD>
</TR>
</table>
<p>
<input type="submit" value="Save">
<input type="submit" value="Cancel" name="btnCancel">
</p>
</form>
</body>
</html>
3.
Save the file as tripedit.cfm in the my_app directory.
Reviewing the code
The following table explains the use of some of the HTML tags in the Trip Edit page. For more
information on HTML, consult any HTML primer.
To test the Trip Edit page:
1.
View the tripedit.cfm page in a browser.
2.
Enter a trip name in the Trip Name field.
3.
Click Save.
An error occurs.
If you view the form source (tripedit.cfm) in an editor, you can see that the
<form> tag has an
action attribute. This attribute indicates the page that receives the form values posted by the
tripedit.cfm page. Because you have not yet created the tripeditaction.cfm page, ColdFusion MX
sends an error.
Tag Description
Form You create a data entry form by using the
form tag. The form tag takes two tag
attributes; for example:
<form action="tripeditaction.cfm" Method= "Post">
Here, the action attribute specifies the name of the ColdFusion file that the web
server will navigate to in response to the form’s submission. The
method attribute
specifies how data is returned to the web server. Submit all ColdFusion forms using
the
Post method attribute.
Table You can format a data entry form and display its controls neatly, by using the table
tag,
table; table row tag, tr; and the table data tag, td.
Form Controls The form requires controls to collect and submit user input. There are a variety of
types of form controls that you can use. For this lesson, you will use the following
controls:
<input> Accepts text answers, such as Trip Name and Trip Price.
<input type=checkbox> Asks yes or no questions, such as Deposit Required?
<select>,<option> Provides user with a list of possible answers, such as the
event type (Mountain Biking, Surfing, and so on).
<textarea> Gathers user input on multiple lines, such as for the Trip Description.
<input type=submit> Posts the information collected to the server.