Updating Data
107
To create an update form:
1
Create a new page in ColdFusion Studio.
2
Edit the page so that it appears as follows:
<cfquery name="GetRecordtoUpdate"
datasource="CompanyInfo">
SELECT *
FROM Employee
WHERE Emp_ID = #URL.Emp_ID#
</cfquery>
<html>
<head>
<title>Update Form</title>
</head>
<body>
<cfoutput query="GetRecordtoUpdate">
<form action="updateaction.cfm" method="Post">
<input type="Hidden" name="Emp_ID"
value="#Emp_ID#"><br>
First Name:
<input type="text" name="FirstName" value="#FirstName#"><br>
Last Name:
<input type="text" name="LastName" value="#LastName#"><br>
Department Number:
<input type="text" name="Dept_ID" value="#Dept_ID#"><br>
Start Date:
<input type="text" name="StartDate" value="#StartDate#"><br>
Salary:
<input type="text" name="Salary" value="#Salary#"><br>
Contractor:
<cfif #Contract# IS "Yes">
<input type="checkbox" name="Contract" checked>Yes<br>
<cfelse>
<input type="checkbox" name="Contract">Yes<br>
</cfif>
<br>
<input type="Submit" value="Update Information">
</form>
</cfoutput>
</body>
</html>
3
Save the page as updateform.cfm.
4
View updateform.cfm in a browser by specifying the page URL and an Employee
ID, for example, http://localhost/myapps/updateform.cfm?Emp_ID=3.
Summary of Contents for COLDFUSION 5-DEVELOPING
Page 1: ...Macromedia Incorporated Developing ColdFusion Applications MacroMedia ColdFusion 5 ...
Page 58: ...38 Chapter 3 Querying a Database ...
Page 134: ...114 Chapter 7 Updating Your Database ...
Page 210: ...190 Chapter 10 Reusing Code ...
Page 232: ...212 Chapter 11 Preventing and Handling Errors ...
Page 238: ...218 Chapter 12 Using the Application Framework ...
Page 262: ...242 Chapter 12 Using the Application Framework ...
Page 278: ...258 Chapter 13 Extending ColdFusion Pages with CFML Scripting ...
Page 320: ...300 Chapter 15 Indexing and Searching Data ...
Page 336: ...316 Chapter 16 Sending and Receiving E mail ...
Page 374: ...354 Chapter 18 Interacting with Remote Servers ...