Jump to content

Confirm Delete on Submit


adriscoll

Recommended Posts

Hello.

 

How can I insert a prompt to confirm the deletion of a record?

 

Currently I have a page that lists all of the table entries with a url to pass along the variable to identify the record to delete on a hidden, secondary page.

 

Page 1

echo "<a href=\"/administrator/db/event_delete2.php?id=$row[id]\">Delete</a>";

 

Page 2

mysql_query("DELETE FROM event_schedule WHERE id='$id' LIMIT 1");

 

The code may be sloppy, but it works.  Now I am trying to add the speedbump of the "are you sure you want to delete this record?"

 

Thank you.

Link to comment
Share on other sites

You'll need to code up a javascript function that implements your confirmation.  Here's one that uses the built-in javascript confirm() dialog.

 

function confirmBox(msg, target) {
  if (confirm(msg)) {
    window.location=target;
  }
}

 

And you'd use it like so:

 

click Me

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.