Chapter 7: Reusing Code
75
<HTML>
<HEAD>
<TITLE>Enter Name</TITLE>
</HEAD>
<BODY>
<!--- Enter a name, which could also be done in a form --->
<!--- This example simply uses a cfset --->
4
<CFSET NameYouEntered="Smith">
<!--- display the current name --->
<CFOUTPUT>
Before you leave this page, you’re #NameYouEntered#.<BR>
</CFOUTPUT>
<!--- go to the custom tag --->
4
<CF_GETMD NAME="#NameYouEntered#">
<!--- come back from custom tag --->
<!--- display the results of the custom tag --->
<CFOUTPUT>
You are now #DOCTOR#.
</CFOUTPUT>
</BODY>
</HTML>
3.
Save the page as
callingpage.cfm
.
4.
Create another new page (the custom tag) in Studio.
5.
Enter the following code:
<HTML>
<HEAD>
<TITLE>GetMD Custom Tag</TITLE>
</HEAD>
<BODY>
<!--- get the value of the varible NAME from the calling page --->
<!--- put the text "Doctor " in front of the name --->
<!--- create a variable called DOCTOR, make its value "Doctor NAME" -
-->
<!--- and make its scope CALLER so that you can pass it back to the
calling page --->
<CFPARAM VALUE="Attributes.Name" DEFAULT="Who"
<CFSET CALLER.DOCTOR="Doctor " & "#ATTRIBUTES.NAME#">
</BODY>
</HTML>
6.
Save the page as
getmd.cfm
.
Summary of Contents for COLDFUSION 4.5-DEVELOPING WEB
Page 1: ...Allaire Corporation Developing Web Applications with ColdFusion ColdFusion 4 5...
Page 14: ...xiv Developing Web Applications with ColdFusion...
Page 26: ...xxvi Developing Web Applications with ColdFusion...
Page 34: ...8 Developing Web Applications with ColdFusion...
Page 70: ...44 Developing Web Applications with ColdFusion...
Page 84: ...58 Developing Web Applications with ColdFusion...
Page 114: ...88 Developing Web Applications with ColdFusion...
Page 148: ...122 Developing Web Applications with ColdFusion...
Page 174: ...148 Developing Web Applications with ColdFusion...
Page 208: ...182 Developing Web Applications with ColdFusion...
Page 244: ...218 Developing Web Applications with ColdFusion...
Page 274: ...248 Developing Web Applications with ColdFusion...
Page 288: ...262 Developing Web Applications with ColdFusion...
Page 300: ...274 Developing Web Applications with ColdFusion...
Page 350: ...324 Developing Web Applications with ColdFusion...
Page 362: ...336 Developing Web Applications with ColdFusion...