DelphiFAQ Home Search:
General :: Web publishing :: JavaScript
Code snippets to add functionality to your HTML pages, preferably cross-browser.


This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

Ask for a confirmation in Javascript before a critical action


How can I prompt a user to confirm critical actions like deleting records?


Use the javascript confirm() function. It looks similar to the alert() box, but has an OK and a CANCEL button.
If the user clicks OK, confirm() will return true.
Otherwise - escape, or click on CANCEL - it will return false.

<script language="JavaScript">
 function confirm_entry(user_name, delete_url)
 input_box=confirm("Do you really want to delete user " + user_name);
 if (input_box==true) { 
   // clicked 'OK', so delete the record
 <a href="javascript:confirm_entry('peter', '/cgi-bin/')">delete peter</a>

Generated 16:01:49 on Sep 22, 2020