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.
Related Articles for Javascripts Navagation:
 |
Delete Warning
Javascript that alert users when clicking on sensitive links (like delete or update links). You can customize the message with option to continue or cancel. Works great with PHP, ASP, and Perl administration sites. |
 |
Source Include
Learn how to save time and money by using the javascript src() function to including local or remote document like headers, footers, css, images, and flash files. |
 |
Telephon Check Box
Javascript code that automatically fills in the telephone number in all places needed after just once entering it and selecting a check box. |
 |
Address Auto-Fill Ckeck Box
Javascript code that automatically fills in the address in all places needed on the page after just once entering it and selecting the check box. |
 |
List of Top Web Hosting sites with
UNLIMITED DISK SPACE |
NewSourceMedia is providing links to these listings as
a courtesy, and makes no representations regarding the content or
any information related thereto. Any questions, complaints or claims
regarding the downloaded content or details must be directed to the appropriate
publisher. We do not encourage or condone the use of any
software in violation of applicable laws.
Comments
iput
01.16.2008
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>
or maybe. like confirmdelete.php, just like that. i beg your pardon, i am not clearly understand.
thank
iput
Joey R
02.26.2005