Closed Thread Icon

Preserved Topic: strange confirm behaviour Pages that link to <a href="https://ozoneasylum.com/backlink?for=18384" title="Pages that link to Preserved Topic: strange confirm behaviour" rel="nofollow" >Preserved Topic: strange confirm behaviour\

 
Author Thread
GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 01-19-2002 20:19

ok, i have a button which deletes a table, i have the following code in the input-tag:

onClick="if(confirm('Are you sure to delete this table?')) {document.editmenu.submit();}"

but no matter if i click on OK or on CANCEL the form gets submitted and the table deleted. am i doing anything wrong?

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 01-19-2002 20:58

You must set input type to "button" (not "submit") if you want to use that code, like this:

<INPUT TYPE="button" onClick="if(confirm('Are you sure to delete this table?')) {document.editmenu.submit();}">


Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 01-19-2002 21:06

Yeah, the submit button submits the form unless its onclick event handler returns false. So you can also replace that with

onClick="if(confirm('Are you sure to delete this table?')) {return true;} else {return false;}"

I may have my true's and false's reversed, you may have to switch them around.

GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 01-20-2002 11:26

thank you guys. it worked!

« BackwardsOnwards »

Show Forum Drop Down Menu