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 Parameters Via URL

One way to pass data from one template to the next is through hyperlinks containing special URL parameters. The HTTP specification allows you to append parameters to the end of a URL in the format:

            filename.cfm?param1=value1&param2=value2&param3=value3

The question mark immediately following the extension of the template in the URL specifies the beginning point for appending URL parameters. Each URL parameter consists of a parameter name followed by an equal sign, then the value assigned to the parameter. You can append more than one URL parameter to a URL by delimiting them with ampersands. Note that no spaces may appear in the URL string unless they are escaped first (see “Dealing with Special Characters”).

When you click on a hyperlink containing one or more URL parameters, those parameters are automatically sent to the template specified in the URL of the link and thus are available to the template as URL variables. The following example illustrates how URL variables are passed from template to template in ColdFusion. The first template, shown in Example 3-1, creates several ColdFusion variables and appends them and their associated values to a URL.

Example 3-1. Creating URL parameters

<!--- Set variables to be passed to another template ---> <cfset x=1> <cfset color="green"> <cfset Pass = True> <h2>Passing Data via URL Parameters</h2> <!--- Create a hyperlink containing URL parameters ---> <cfoutput> <a href="receiveurlparameters.cfm?x=#x#&color=#color#&pass=#pass#">Click ...
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