dan678
10-01-2003, 07:16 PM
<script language=JavaScript><!-- Hide script
function ConfirmDelete() {
if (confirm("Are you sure you want to delete this Caprate?\n" +
"This is your last chance to cancel."))
return true;
return false;
}
//-->
</script>
<form action="#cgi.script_name#" method="POST">
...
<input type="submit" name="delete" value="Delete" tabindex="14" onClick="return ConfirmDelete();">
...
I have a form that lists 1 record from a table. There is a "Delete" button that when the user pushes, a window prompts them asking them if they want to really delete this record.
Can I have a prompt that is similiar to the above javascript activated when a user selects a hyperlink such as:
<a href="del_caprate.cfm?ID=#ID#">Delete</a>
In order to use the above Javascript code, I have to use a button inside a form. Sometimes, I want to be able to use this same prompt when they select a hyperlink that essentially does the same thing. In this case, I don't want to use a form. I need to use a hyperlink using the above code. Basically, I don't want them to accidentally hit this "Delete" hyperlink and deletes the record without a confirmation popping up.
Does anyone know how to tie in the above javascript or something similar to achieve the effect that I'm trying to make? Thanks for any inputs.
P.S. I'm just learning Javascript right now.
function ConfirmDelete() {
if (confirm("Are you sure you want to delete this Caprate?\n" +
"This is your last chance to cancel."))
return true;
return false;
}
//-->
</script>
<form action="#cgi.script_name#" method="POST">
...
<input type="submit" name="delete" value="Delete" tabindex="14" onClick="return ConfirmDelete();">
...
I have a form that lists 1 record from a table. There is a "Delete" button that when the user pushes, a window prompts them asking them if they want to really delete this record.
Can I have a prompt that is similiar to the above javascript activated when a user selects a hyperlink such as:
<a href="del_caprate.cfm?ID=#ID#">Delete</a>
In order to use the above Javascript code, I have to use a button inside a form. Sometimes, I want to be able to use this same prompt when they select a hyperlink that essentially does the same thing. In this case, I don't want to use a form. I need to use a hyperlink using the above code. Basically, I don't want them to accidentally hit this "Delete" hyperlink and deletes the record without a confirmation popping up.
Does anyone know how to tie in the above javascript or something similar to achieve the effect that I'm trying to make? Thanks for any inputs.
P.S. I'm just learning Javascript right now.