{"id":838,"date":"2012-11-28T21:51:49","date_gmt":"2012-11-28T16:51:49","guid":{"rendered":"http:\/\/www.esearing.com\/v2010\/?p=838"},"modified":"2013-01-08T20:26:09","modified_gmt":"2013-01-08T15:26:09","slug":"coldfusion-ajax-updating-a-database-from-any-page-link","status":"publish","type":"post","link":"https:\/\/www.esearing.com\/v2010\/2012\/11\/coldfusion-ajax-updating-a-database-from-any-page-link\/","title":{"rendered":"Coldfusion AJAX updating a database from any page link"},"content":{"rendered":"<p>I had an interesting situation where I needed to Tag orders as &#8220;Reviewed&#8221; in a database so they could be filtered out in future queries.<\/p>\n<p>I wrote my standard query form form to limit results as usual, added filter (reviewed, not Reviewed, All) as a select box<br \/>\nand then added a column to my output results which allows the user to click a link\/checkbox to update a table.<br \/>\n<code><br \/>\n&lt;cfoutput query=\"myqueryname\"&gt;<br \/>\n-- all the query results in a table  displayed as web page plus one more column<br \/>\n&lt;td&gt;<br \/>\n&lt;cfdiv name=\"cboxdiv\"<br \/>\n    &lt;input type=\"checkbox\" name=\"tagthis\" onclick=\"#AjaxLink('myCFMname.cfm?order_number=#order_number#')#\" \/&gt;<br \/>\n&lt;\/cfdiv&gt;<br \/>\n&lt;\/td&gt;<br \/>\n&lt;\/cfoutput&gt;<br \/>\n<\/code><\/p>\n<p>myCFMname.cfm  (called by ajaxLink)<br \/>\n<code><br \/>\n-- Full page with doctype, head, body tags<br \/>\n&lt;cfquery  name=\"ins_tag\" datasource=\"myDSN\"&gt;<br \/>\n        insert into MYTable (order_number reviewed_flag, reviewed_who, reviewed_when)<br \/>\n        values('#order_number#', 'Y', '#gettoken(user_email,\"1\", \"@\")#', getdate())<br \/>\n&lt;\/cfquery&gt;<br \/>\n-- replace the checkbox with message<br \/>\n &lt;p&gt;Reviewed&lt;\/p&gt;<br \/>\n<\/code><br \/>\nAt a later date I added an UNDO\/Delete Flag feature. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>I had an interesting situation where I needed to Tag orders as &#8220;Reviewed&#8221; 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, &hellip; <a href=\"https:\/\/www.esearing.com\/v2010\/2012\/11\/coldfusion-ajax-updating-a-database-from-any-page-link\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,16],"tags":[57],"class_list":["post-838","post","type-post","status-publish","format-standard","hentry","category-code","category-coldfusion","tag-ajaxlink"],"_links":{"self":[{"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/posts\/838","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/comments?post=838"}],"version-history":[{"count":3,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/posts\/838\/revisions"}],"predecessor-version":[{"id":915,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/posts\/838\/revisions\/915"}],"wp:attachment":[{"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/media?parent=838"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/categories?post=838"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/tags?post=838"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}