
162
Chapter 9 Building Dynamic Forms
Reviewing the code
The following table describes the code and its function:
Code
Description
<cfif isdefined
("Form.employee_grid.rowstatus.action")>
<cfloop index = "Counter" from = "1" to =
#arraylen(Form.employee_grid.rowstatus.action)#>
If there is an array of edit types, then the
table needs changing. Otherwise, do
nothing. Loop through the remaining code
once for each row to be changed. Counter
is the common index into the arrays of
change information for the row being
changed.
<cfoutput>
The row action for #Counter# is:
#Form.employee_grid.rowstatus.action[Counter]#
<br>
</cfoutput>
Display the action code for this row:
U, I, or D.
<cfif Form.employee_grid.rowstatus.action[counter]
is "D">
<cfquery name="DeleteExistingEmployee"
datasource="CompanyInfo">
DELETE FROM Employee
WHERE
Emp_ID=#Form.employee_grid.original
.Emp_ID[Counter]#
</cfquery>
If the action is to delete a row, generate a
SQL DELETE query specifying the
Emp_ID (the primary key) of the row to be
deleted.
<cfelseif Form.employee_grid.rowstatus.action
[counter] is "U">
<cfquery name="UpdateExistingEmployee"
datasource="CompanyInfo">
UPDATE Employee
SET LastName=
’#Form.employee_grid.LastName[Counter]#’,
Dept_ID=
#Form.employee_grid.Dept_ID[Counter]#
WHERE
Emp_ID=#Form.employee_grid.original.
Emp_ID[Counter]#
</cfquery>
Otherwise, if the action is to update a row,
generate a SQL UPDATE query to update
the LastName and Dept_ID fields for the
row specified by the Emp_ID primary table
key.
Содержание COLDFUSION 5-DEVELOPING
Страница 1: ...Macromedia Incorporated Developing ColdFusion Applications MacroMedia ColdFusion 5 ...
Страница 58: ...38 Chapter 3 Querying a Database ...
Страница 134: ...114 Chapter 7 Updating Your Database ...
Страница 210: ...190 Chapter 10 Reusing Code ...
Страница 232: ...212 Chapter 11 Preventing and Handling Errors ...
Страница 238: ...218 Chapter 12 Using the Application Framework ...
Страница 262: ...242 Chapter 12 Using the Application Framework ...
Страница 278: ...258 Chapter 13 Extending ColdFusion Pages with CFML Scripting ...
Страница 320: ...300 Chapter 15 Indexing and Searching Data ...
Страница 336: ...316 Chapter 16 Sending and Receiving E mail ...
Страница 374: ...354 Chapter 18 Interacting with Remote Servers ...