Powered by InterCreatives | Site Map
Search:
NewSourceMedia Popular Tutorials: PHP Javascripts Web Hosting
SoftwareTutorials
CATEGORIES
Job Listings
 
Home / Javascripts / Navagation

Delete Warning

Published by: Alexander McLean III


Introduction:

This javascript registers an event handler to a link on a page. When users click a link, the code executes a pop-up alert window asks them to confirm that this is the link they wanted to click. This is perfect for server side programs that delete files on a server or modify data in a database. (View the test page.)

Source Code:

<script>
function confirmDelete(delUrl,name_cat) {
if (confirm("Are you sure you want to delete nrow number "" name_cat ""nfrom the database")) {
document.location = delUrl;
}
}
</script>

<!-- now the html link -->

<a href="javascript:confirmDelete('yourpage.php?delete=293','293')">Delete</a>


Adding it to your site:

There are just a few areas you will need to change to customize the code for your use. Number one is the message inside of the javascript event handler ("Are you sure you want to delete nrow number "" name_cat ""nfrom the database"). Notice I used (n) for a new line and (") for quotes. You can delete them if you like. You can also delete or move around the (" name_cat ") inside the message.

The second thing you will have to modify is the link values ('yourpage.php?delete=293','293'). Change the file name to your serverside program file path and change the id row numbers ('293') to the id row number of your database rows.


Next Javascripts Page:
1  [2]  3  4  5  6  7  8  9  10  11  12 





Hosting by iPowerWeb.com - 50 Gb for $7.95