Forum Moderators: open

Message Too Old, No Replies

Alert box question

         

kevinj

9:40 pm on Mar 26, 2004 (gmt 0)

10+ Year Member



I have a form that when filled out and the submit button is clicked shows an alert box asking the user if they want to submit this order. Is there a way to get the alert box to have an "OK" and a "Cancel"? Right now I just have an "OK" and if they click the close window icon top left it still puts the order through.

digitalv

9:45 pm on Mar 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Javascript:

<script LANGUAGE="JavaScript">
function confirmSubmit()
{
var agree=confirm("Confirm: Do this?");
if (agree)
return true ;
else
return false ;
}
</script>

==============
In your form/button/whatever:

onClick="return confirmSubmit()"

make sure you do the "return" part of that - if you just do onClick=confirmSubmit() it will always default to the "OK" and not the cancel. Having return in there allows for "nothing" to happen if the user clicks cancel.

kevinj

11:01 pm on Mar 26, 2004 (gmt 0)

10+ Year Member



Thanks! Works perfect.

Kevin