View Full Version : Simple confirm code not working

07-02-2004, 06:26 AM
This is probably just a stupid mistake that I'm missing, but I'm using this code to confirm a choice to delete a post:

function prepsub {
var ask = window.confirm("Are you sure you want to delete the selected post?");
if (ask) {

The HTML code I use is this:

<button onclick="javascript:prepsub();">Delete Selected Post</button>

I think I heard that the <button> tag is deprecated, and that might be the reason, but I don't think it is because I've successfully used it for other similar purposes before.

For some reason on Mozilla it doesn't show the confirm dialog box ask must return true because it goes ahead and submits it. On IE it doesn't show the confirm box and refuses to submit at all. Am I making a stupid mistake here?


07-02-2004, 06:40 AM
Right off i can see you are missing your parenthesis:

function prepsub()

There might be something else but try that first.

07-02-2004, 09:18 AM
<script type="text/javascript">
function prepsub() {
return window.confirm("Are you sure you want to delete the selected post?\n\nReally?\n\nDo you have thought about it long enough?\n\nI mean.. you can't get your post..\n\nSo.. are you really really sure?\n\nDon't want to think about it twice?\n\nAm I annoying you? ^^");
<form onSubmit="return prepsub()">
<input type="submit" name="delete" value="delete selected post">

This works. :D

07-02-2004, 04:41 PM
Thanks for the code even if the confirm will take a little editing lol. ;)

07-02-2004, 06:05 PM
<button onclick="javascript:prepsub();">Delete Selected Post</button>

<input type="button">