[thelist] JAVASCRIPT: confirmation dialog box that actually works!

Tom Dell'Aringa pixelmech at yahoo.com
Thu Aug 29 11:51:32 CDT 2002


--- "Chris W. Parker" <cparker at swatgear.com> wrote:
i want the form
> submission
> to just be canceled.


Chris, you need something like this:

function confirmDelete()
{
   if (confirm('You cannot undo this operation. Are you sure you want
to delete this item? (Click \'OK\' to delete this product, click
\'Cancel\' to keep it.'))
   {
      return true;
   }
return false;
}

In my case, I am calling this simply from a link with an onClick, but
you can call it from the onSubmit handler when you send a form. If
they click ok, it returns true, and the form is submitted, if they
click cancel it returns false, and the form submit is cancelled.

Remember you must use return before your function call:

onsubmit="RETURN confirmDelete()"

or else it won't work.

HTH

Tom


=====
var me = tom.pixelmech.webDeveloper();

http://www.pixelmech.com/
http://www.maccaws.com/
[Making A Commercial Case for Adopting Web Standards]

__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com



More information about the thelist mailing list