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.
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.