Welcome to WebmasterWorld Guest from 174.129.151.95

Forum Moderators: open

Message Too Old, No Replies

onSubmit not returning false!

help please!

   
5:59 pm on Jun 20, 2003 (gmt 0)

WebmasterWorld Senior Member dreamcatcher is a WebmasterWorld Top Contributor of All Time 10+ Year Member



I`m coding a guestbook and I want a message to appear when someone clicks "Delete" to say something like "Are you Sure?", then ok returns true, cancel returns false.

The code, which someone here gave me (can`t remember who) is as follows:

<script language="JavaScript" type="text/JavaScript">

function submitConfirmation()

{

var confirmSub = confirm("Are you sure?");
if (confirmSub)

{

return true;

}

else

{

return false;

}

}

</script>

Then I use the onsubmit = submitConfirmation(); in the form tag.

The code is displaying ok, in the sense that the box appears ok, saying "Are you sure?", but its not returning false if cancel is clicked. The entry gets deleted if ok or cancel are clicked.

Any ideas please?

Thank you.

6:02 pm on Jun 20, 2003 (gmt 0)

WebmasterWorld Senior Member korkus2000 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Try this as your onsubmit:

onsubmit="return submitConfirmation();"

6:37 pm on Jun 20, 2003 (gmt 0)

WebmasterWorld Senior Member dreamcatcher is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Thanks Korkus2000. I think you might have been the one who gave me the code originally.

Anyway, yep, that works fine. Thanks.

:)

6:37 pm on Jun 20, 2003 (gmt 0)

WebmasterWorld Senior Member korkus2000 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



;)