Good afternoon.
I have a form which is used to maintain employee information. When editing an existing employee, the form has both an delete and update button.
This is the code for the buttons:
<input type="submit" value=" #formAction# " name="#formAction#">
<cfif NOT compareNoCase(formAction,"Update"
>
<input type="submit" value=" Delete " name="Delete" >
<input type="reset" value=" Reset ">
<input type="button" value=" Cancel " onClick="document.location.href='javascript:history.back();'">
The formaction variable can be Insert or Update. I am concerned with the case where it is Update, because that is when I get both an Update and Delete button.
I want to show a confirm box to confirm any deletions.
I found this Javascript:
<!--- this script confirms deletes, I hope --->
<SCRIPT LANGUAGE="JavaScript">
function confirmDelete() {
if (confirm("Are you sure you want to delete this employee?"
) {
return true;
}
else {
return false;
}
}
</script>
and I added it to the page and edited the buttons so that the Delete button read:
<input type="submit" value=" Delete " name="Delete" onClick ="return confirmDelete();" >
When I ran the page, the Javascript didn't run, apparently. The form posted to the post page and the data was deleted with no confirmation.
The post page differentiates between the actions and runs the apppropriate query as follows:
<cfif isDefined("form.insert"
>
<cfmodule
template="qryInsertRecord.cfm"
table="#table#">
<cfset verb="inserted">
<cfelseif isDefined("form.update"
>
<cfmodule
template="qryUpdateRecord.cfm"
table="#table#"
ID="#ID#">
<cfset verb="updated">
<Cfelseif isDefined("form.Delete"
>
<cfmodule
template="qryDeleteRecord.cfm"
table="#table#"
ID="#ID#">
<cfset verb="deleted">
</cfif>
Can anyone shed some light on how to do what I want?
Kathryn
I have a form which is used to maintain employee information. When editing an existing employee, the form has both an delete and update button.
This is the code for the buttons:
<input type="submit" value=" #formAction# " name="#formAction#">
<cfif NOT compareNoCase(formAction,"Update"
<input type="submit" value=" Delete " name="Delete" >
<input type="reset" value=" Reset ">
<input type="button" value=" Cancel " onClick="document.location.href='javascript:history.back();'">
The formaction variable can be Insert or Update. I am concerned with the case where it is Update, because that is when I get both an Update and Delete button.
I want to show a confirm box to confirm any deletions.
I found this Javascript:
<!--- this script confirms deletes, I hope --->
<SCRIPT LANGUAGE="JavaScript">
function confirmDelete() {
if (confirm("Are you sure you want to delete this employee?"
return true;
}
else {
return false;
}
}
</script>
and I added it to the page and edited the buttons so that the Delete button read:
<input type="submit" value=" Delete " name="Delete" onClick ="return confirmDelete();" >
When I ran the page, the Javascript didn't run, apparently. The form posted to the post page and the data was deleted with no confirmation.
The post page differentiates between the actions and runs the apppropriate query as follows:
<cfif isDefined("form.insert"
<cfmodule
template="qryInsertRecord.cfm"
table="#table#">
<cfset verb="inserted">
<cfelseif isDefined("form.update"
<cfmodule
template="qryUpdateRecord.cfm"
table="#table#"
ID="#ID#">
<cfset verb="updated">
<Cfelseif isDefined("form.Delete"
<cfmodule
template="qryDeleteRecord.cfm"
table="#table#"
ID="#ID#">
<cfset verb="deleted">
</cfif>
Can anyone shed some light on how to do what I want?
Kathryn