Skip to Main Content
Programming ColdFusion MX, 2nd Edition
book

Programming ColdFusion MX, 2nd Edition

by Rob Brooks-Bilson
August 2003
Intermediate to advanced content levelIntermediate to advanced
1140 pages
68h 45m
English
O'Reilly Media, Inc.
Content preview from Programming ColdFusion MX, 2nd Edition

Passing Data Using Forms

Another method for passing data from template to template involves sending the data via the HTTP Post method as form-field data. When you create an HTML form that posts to another ColdFusion template, each form field is automatically available as a form variable within the template specified in the action attribute of the form tag. Within the receiving template, each form field can be referenced by prefixing the field name with form, as in form. MyField. To see just how this works, let’s look at an example. The contactform.cfm template, shown in Example 3-6, creates a simple HTML form that collects basic contact information and posts it to the displaycontactinfo.cfm template, shown in Example 3-7.

Example 3-6. Template for collecting and posting contact information

<html> <head> <title>Passing Variables via Form Fields</title> </head> <body> <h2>Employee Contact Information</h2> <form action="displaycontactinfo.cfm" method="post"> <table> <tr> <td>Name:</td> <td><input type="text" name="Name" size="25" maxlength="50"></td> </tr> <tr> <td>Title:</td> <td><input type="text" name="Title" size="25" maxlength="50"></td> </tr> <tr> <td>Department:</td> <td><input type="text" name="Department" size="25" maxlength="50"></td> </tr> <tr> <td>E-mail:</td> <td><input type="text" name="Email" size="25" maxlength="255"></td> </tr> <tr> <td>Phone Ext.:</td> <td><input type="text" name="PhoneExt" size="6" maxlength="4"></td> </tr> <tr> <td colspan="2"><input type="submit" ...
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.
Start your free trial

You might also like

Programming ColdFusion

Programming ColdFusion

Rob Brooks-Bilson

Publisher Resources

ISBN: 0596003803Supplemental ContentErrata Page