I programmed for a long time checking for StructKeyExists(form,"Update") until I change my input from type="submit" to type="image". IE doesn't send the name of the control back when type="image", but instead sends Update.X and Update.Y.
<form method="post">
Old Way:<br />
<input type="submit" value="3" name="Update" /><br />
<input type="submit" value="4" name="Delete" />
<p>New Way:</p>
<input type="image" value="1" name="Update" src="http://www.google.com/intl/en_ALL/images/logo.gif" /><br />
<input type="image" value="2" name="Delete" src="http://images.google.com/intl/en_ALL/images/logos/images_logo_lg.gif" />
</form>
My first thought was that I should just add two characters to my logic
from: <cfif StructKeyExists(form,"Update")
to: <cfif StructKeyExists(form,"Update.X")
But I would like a solution that handles both type="submit" and type="image". Right now my logic is:
<cfif StructKeyExists(form,"Update") OR StructKeyExists(form,"Update.X")>
<!--- UPDATE table --->
<cfelseif StructKeyExists(form,"Delete") OR StructKeyExists(form,"Delete.Y")>
<!--- DELETE FROM Table --->
</cfif>
Q: Is there a more elegant way to check for which button has been pressed? Assuming there is more than one button on the form of course, because if I only had to check to see if the form was submitted, I would check to see if form.fieldnames existed.