Page 1 of 1

confirm box

Posted: Fri Sep 03, 2004 6:03 pm
by Think Pink
hello. pl help with the follwing;

I want to make a confirm box. If someone clicks OK, the form is submitted, if clickes Cancel nothing happends.

This is what I have so far:

Code: Select all

<script language="JavaScript">
<!--
function confirm_entry()
&#123;
var agree=confirm("OK to Continue \r Cancel to stop the execution");
if (agree)

&#123; 
// when ok is pressed the form is submitted
&#125;

else
&#123;
// when cancel is pressed nothing happends
&#125;
&#125;
-->
</script>

<form name="" action="test.php" method="post" onSubmit="confirm_entry();">
<input type="submit">
</form>
in this situation, if I click ok, the form is submitted, but the same thing is happening if i click cancel

Posted: Fri Sep 03, 2004 6:07 pm
by feyd
try

Code: Select all

function confirm_entry()
&#123;
  return confirm('OK to Continue\nCancel to stop the execution');
&#125;

confirm box

Posted: Fri Sep 03, 2004 6:19 pm
by Think Pink
not working

Posted: Fri Sep 03, 2004 6:43 pm
by voltrader
This works:


Code: Select all

<script language="JavaScript">
<!--
function confirm_entry()
&#123;
var agree=confirm("OK to Continue \r Cancel to stop the execution");
if (agree)

&#123;
// when ok is pressed the form is submitted
&#125;

else
&#123;
// when cancel is pressed nothing happends
return false;
&#125;
&#125;
-->
</script>

<form name="" action="test.php" method="post" onSubmit="return confirm_entry();">
<input type="submit">
</form>

confirm box

Posted: Sun Sep 05, 2004 1:55 pm
by Think Pink
thx. works great

Posted: Mon Sep 06, 2004 1:27 am
by Pyrite
Cool.