Coldfusion AJAX updating a database from any page link

I had an interesting situation where I needed to Tag orders as “Reviewed” in a database so they could be filtered out in future queries.

I wrote my standard query form form to limit results as usual, added filter (reviewed, not Reviewed, All) as a select box
and then added a column to my output results which allows the user to click a link/checkbox to update a table.

<cfoutput query="myqueryname">
-- all the query results in a table displayed as web page plus one more column
<td>
<cfdiv name="cboxdiv"
<input type="checkbox" name="tagthis" onclick="#AjaxLink('myCFMname.cfm?order_number=#order_number#')#" />
</cfdiv>
</td>
</cfoutput>

myCFMname.cfm (called by ajaxLink)

-- Full page with doctype, head, body tags
<cfquery name="ins_tag" datasource="myDSN">
insert into MYTable (order_number reviewed_flag, reviewed_who, reviewed_when)
values('#order_number#', 'Y', '#gettoken(user_email,"1", "@")#', getdate())
</cfquery>
-- replace the checkbox with message
<p>Reviewed</p>

At a later date I added an UNDO/Delete Flag feature.

Cup size   
Select size then click on coffee cup.
This entry was posted in Code, Coldfusion and tagged . Bookmark the permalink.