Guys,
what is worng with my sysntax
<cfif button eq "Delete">
<cflocation url="del.cfm?id=#id#" onclick="if(confirm('Are you sure you want
to delete #title#?') == false) return false;" title="delete">
</cfif
==============
ERROR:
Attribute validation error for tag CFLOCATION.
The tag does not allow the attribute(s) TITLE,ONCLICK. The valid attribute(s)
are ADDTOKEN,URL.
========================
I know the cflocation tag does not allow these, but what can I do to make it
work?
Thanks
Adam Cameron - 21 Mar 2006 23:54 GMT
> <cflocation url="del.cfm?id=#id#" onclick="if(confirm('Are you sure you want
> to delete #title#?') == false) return false;" title="delete">
Maybe you should read the docs...
http://livedocs.macromedia.com/coldfusion/7/htmldocs/00000284.htm
<cflocation> does not have an ONCLICK argument. How would you expect that
to work...?

Signature
Adam
zoeski80 - 22 Mar 2006 01:46 GMT
Could try something like this...
You need to put the JS into the form, cannot put it on the CFLOCATION.
Other alternative is on process page have a check for which button was clicked
and have your confirmation message output to the screen rather than a JS
confirm box with a link for YES going to the del.cfm?id=#form.id# page and the
NO link going somewhere else.
HTH
<cfform action="" method="post">
<cfinput type="hidden" name="id" value="#id#">
<cfinput type="submit" name="button" value="Edit" class="buttonon">
<cfinput type="submit" name="button" value="Archive" class="buttonon">
</cfform>
<cfform name="myForm" action="del.cfm" method="post" onSubmit="return
confirm('Are you sure you want to delete #title#?')">
<cfinput type="hidden" name="id" value="#id#">
<cfinput type="submit" name="button" value="Delete" class="buttonon">
</cfform>
BKBK - 23 Mar 2006 16:20 GMT
You could add the following to the suggestions from Adam and Zoe. It comes in 3
files, formPage.cfm, confirm_del.cfm and del.cfm.
formPage.cfm
==============
<cfset id = 123>
<cfset title="xyz">
<cfif isDefined("form.button")>
<cfif form.button eq "Delete">
<cflocation url="test1.cfm?id=#id#&title=#title#">
<cfelseif form.button eq "Edit">
<!--- Edit --->
<cfelse>
<!--- Archive --->
</cfif>
</cfif>
<cfform action="#cgi.script_name#" method="post">
<cfinput type="hidden" name="id" value="#id#">
<cfinput type="submit" name="button" value="Edit" class="buttonon">
<cfinput type="submit" name="button" value="Delete" class="buttonon">
<cfinput type="submit" name="button" value="Archive" class="buttonon">
</cfform>
confirm_del.cfm
================
<html>
<head>
<title>Confirm delete</title>
<cfoutput>
<script type="text/javascript">
function confirm_del() {
var x = confirm('Are you sure you want to delete #title#? (ID: #id#)');
if (x == true) {
/* User confirms intention to delete. Redirect user to del page */
window.location = "del.cfm?id=#id#&title=#title#";
}
else {
/* User does not wish to delete after all. Send user back to form page */
window.location = "formPage.cfm?id=#id#&title=#title#";
}
}
</script>
</cfoutput>
</head>
<body onload="confirm_del()">
<cfif isDefined("URL.id")>
<cfset id = #URL.id#>
</cfif>
<cfif isDefined("URL.title")>
<cfset title = #URL.title#>
</cfif>
</body>
</html>
del.cfm
=========
<cfif isDefined("URL.id")>
<cfset id = #URL.id#>
</cfif>
<cfif isDefined("URL.title")>
<cfset title = #URL.title#>
</cfif>
<!--- [Code to delete title goes here] --->
newcf - 29 Mar 2006 18:15 GMT