Thursday, 5 September 2013

Execute cfquery after button press or behind the scenes action page?

Execute cfquery after button press or behind the scenes action page?

My page creates a few random variables to pick prizes and winners for a
drawing, and I want to write the prize winners and their prizes to a table
after the winner clicks a button to claim the prize.
The problem is I want them to stay on the page so that a prize can be
picked again if it isn't claimed.
The best solution I can come up with is an action page that the cfinput
button references, but I don't want the action page to open up, I just
want the cfquery on that page to run behind the scenes.
Here's an example:
<cfquery name="updateQuantity" datasource="christmas">
UPDATE PRIZES
SET QUANTITY = QUANTITY - 1
WHERE prize_ID = #prizeID#
</cfquery>
I tried making my button a "submit" button and using cfif
isDefined("form.Submit") to run the cfquery on the same page, but the
submit button refreshes the page and writes the next picked winner instead
of the prizeID of the current session.

No comments:

Post a Comment