Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 745

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Requesting and Presenting Information
<cfelseif Form.employee_grid.rowstatus.action[counter] is "I">
<cfquery name="InsertNewEmployee"
datasource="cfdocexamples">
INSERT into Employee (LastName, Dept_ID)
VALUES (<cfqueryparam
</cfquery>
</cfif>
</cfloop>
</cfif>
Click <a href="grid2.cfm">here</a> to display updated grid.
</body>
</html>
Rename your existing handle_grid.cfm file as handle_grid2.cfm to save it, and then save this file as
2
handle_grid.cfm.
3
View the grid2.cfm page in your browser, change the grid, and then submit them.
Reviewing the code
The following table describes the code and its function:
Code
<cfif isdefined("Form.employee_grid.rowstatus.action")>
<cfloop index = "counter" from = "1" to =
#arraylen(Form.employee_grid.rowstatus.action)#>
<cfoutput>
The row action for #counter# is:
#Form.employee_grid.rowstatus.action[counter]#
<br>
</cfoutput>
<cfif Form.employee_grid.rowstatus.action[counter] is "D">
<cfquery name="DeleteExistingEmployee"
datasource="cfdocexamples">
DELETE FROM Employee
WHERE Emp_ID=<cfqueryparam
value="#Form.employee_grid.original.Emp_ID[counter]#"
CFSQLType="CF_SQL_INTEGER" >
</cfquery>
value="#Form.employee_grid.LastName[counter]#"
CFSQLType="CF_SQL_VARCHAR" >,
<cfqueryparam value="#Form.employee_grid.Dept_ID[counter]#"
CFSQLType="CF_SQL_INTEGER" >)
Last updated 1/20/2012
Description
If there is an array of edit types, changes the table.
Otherwise, does nothing. Loops through the remaining
code once for each row to be changed. The
variable is the common index into the arrays of change
information for the row being changed.
Displays the action code for this row: U for update, I for
insert, or D for delete.
If the action is to delete a row, generates a SQL DELETE
query specifying the Emp_ID (the primary key) of the
row to be deleted.
740
counter

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents