[thelist] javascript confirm dual submit nastiness

Jason Bauer jbauer at chimesnet.com
Fri Nov 22 12:24:16 CST 2002

> I've got a form with TWO submit buttons - one is edit one is delete.
> Depending on which button is pressed, my php page either gives the
> user an edit form with the variable passed by the form filled in - or
> it simply deletes the item.
> Now, of course I want them to confirm the deletion. Here's the
> trouble. I can't use the onClick event handler since its a submit
> button. (Although I tried various ways to make this work, such as
> setting theform.submit = false while passing this.form, which
> failed).

Why don't you do this check on the page you are submitting to? If they
selected delete, you can display the item with another set of buttons to
Confirm or Cancel the delete.

This method has two big benefits. First, they get the option of viewing
whatever it is that they are deleting, so they don't accidentally delete
something because of a typo. Secondly, it will work for non-JavaScript

This should be pretty simple if your posting to the same page, you'll just
have four if blocks. One if nothing is submitted (display form), 1 for
Delete button (show confirm page), 1 for Delete Confirmed (delete record)
and 1 for Edit record.

Jason Bauer
jbauer at chimesnet.com
Chimes, Inc.

More information about the thelist mailing list