I have a form where the user has the option of deleting an item from a database. I have the following Javascript function set up:
function DeleteMe()
{
if (confirm ("Are you sure you want to delete the selected project?"
)
{
document.forms[0].submit();
}
else
{
return false
}
}
In the form, I have the following set for the Delete button:
<INPUT TYPE="submit" NAME="Button" VALUE="Continue">
<INPUT TYPE="submit" NAME="Button" VALUE="Save">
<INPUT TYPE="button" NAME="Button" VALUE="Delete" ONCLICK="DeleteMe()">
On my action page, I have the following code set up:
<CFIF IsDefined ("form.button"
>
do this
<CFELSE>
do that
</CFIF>
If the user selects "Cancel" on the confirm message, nothing happens (as is expected). However, when the user selects "OK", the ELSE statement on the action page gets invoked. The problem is that the Delete button is not getting recognized (on the Action page, if I say something like IsDefined "form.button" - I get an error). I'm sure that this has something to do with the fact that I am using the buttons within CFFORM (rather than a simple FORM) and trying to submit the form using a Javascript function.
Any ideas on how to resolve this problem?
function DeleteMe()
{
if (confirm ("Are you sure you want to delete the selected project?"
{
document.forms[0].submit();
}
else
{
return false
}
}
In the form, I have the following set for the Delete button:
<INPUT TYPE="submit" NAME="Button" VALUE="Continue">
<INPUT TYPE="submit" NAME="Button" VALUE="Save">
<INPUT TYPE="button" NAME="Button" VALUE="Delete" ONCLICK="DeleteMe()">
On my action page, I have the following code set up:
<CFIF IsDefined ("form.button"
do this
<CFELSE>
do that
</CFIF>
If the user selects "Cancel" on the confirm message, nothing happens (as is expected). However, when the user selects "OK", the ELSE statement on the action page gets invoked. The problem is that the Delete button is not getting recognized (on the Action page, if I say something like IsDefined "form.button" - I get an error). I'm sure that this has something to do with the fact that I am using the buttons within CFFORM (rather than a simple FORM) and trying to submit the form using a Javascript function.
Any ideas on how to resolve this problem?