We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Alert before delete

fackz
fackz asked
on
Medium Priority
2,289 Views
Last Modified: 2013-12-12
Hey guys, I have this code to delete some data from my db:

<a href="?acao=delete&id=<?php echo $row['id'] ?>">Delete</a>

How can I add a javascript alert that ask the user to confirm or cancel before delete the data?!
Comment
Watch Question

Loganathan NatarajanLAMP Developer
CERTIFIED EXPERT

Commented:
simple way,


<a href="?acao=delete&id=<?php echo $row['id'] ?>" onclick="return confirm('Do you want to really delete?');">Delete</a>

Open in new window

erikTsomikSystem Architect, CF programmer

Commented:
LAMP Developer
CERTIFIED EXPERT
Commented:

<html>
<head>
<script language="JavaScript">
function confirmSubmit() {
var agree=confirm("Are you sure you wish to continue?");
if (agree)
     return true;
else
     return false;
}
</script>
</head>
 
<body>
<a href="?acao=delete&id=<?php echo $row['id'] ?>" onclick="return confirmSubmit()" >Delete </a>
</body>
</html>

Open in new window

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
exactly what I need...thank you very much!
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.