Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript confirm box and delete query

Status
Not open for further replies.
Joined
Aug 18, 2003
Messages
111
Location
GB
I'm trying to write a confirmation box so that when a user clicks ok a delete query is run and if cancel is clicked nothing happens. The code i tried is listed below, which doesn't work, probably because its taken from different books. If anyone knows an easier way or a way that works. please help.


var tmpAction = "";
function checktext() {
if (tmpAction == "delete")
{window.confirm('Are you sure you want to delete contact?');
window.status=(temp)?'confirm: true':'confirm: false';}
return true;}
</script>


<cfif isdefined("form.delete")>
<script language="javascript" >
if (temp == "true")
<cfquery name="delete" datasource="saleswebtest">
delete from markcontacts
where recno='#form.recno#'
</cfquery>
opener.location.href=" window.close();
</script>
</cfif>


Cheers
Pete

If it ain't broke, don't fix it!
 
Here is what I use:
<!---Link to call script --->
<a href="javascript: confirmDelete('#qListPOC.firstName#','#qListPOC.lastname#',#qListPOC.pocID#);" >Delete</a>

<!--- confirm function --->
<script language = "javascript">
function confirmDelete(firstName, lastName, POCID){
action = false;
action = confirm("Are you sure you want to delete: " + firstName +" "+ lastName);
if (action){
window.location = "deletePOC.cfm?pocid="+POCID
}
}
</script>

<!--- delete page --->
<cfparam name = "url.pocid" default = "1">
<cfquery datasource="#application.dsn#">
Delete from TMStoPOC where pocID = '#url.pocid#'
</cfquery>
<cfquery datasource="#application.dsn#">
Delete from contacts where pocID = '#url.pocid#'
</cfquery>
<cflocation url="listpoc.cfm">

Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
-Douglas Adams (1952-2001)
 
To be invisible one might even open it a new window and then close it so the usero remains on the same page

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
you'd have to do a opener.reload to refresh the page. the way I do it, the cflocation goes back to the page with the updated info.

Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
-Douglas Adams (1952-2001)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top