Pop up message when you click submit

Hi
Ive this line of code, which is a send button, but I’m trying to get a pop up message once I press it saying “are you sure you want to send” but where ever I put it in it doesnt work

<td colspan="1" align="right"><input type="button" value="Send Invoices &raquo;" onclick="document.checkmail.submit();"></td>

I’ve tried putting it here


<td colspan="1" align="right"><input type="button" value="Send Invoices &raquo;" onclick="document.checkmail.submit()(Are you sure you want to send these);"></td>

This is a Javascript question rather than ColdFusion so for a better response you’d be better directing this here: http://www.sitepoint.com/forums/forumdisplay.php?f=15

Alternatively do a Google as you’ll find plenty of examples / tutorials of this kind of thing :wink:

Please do not use inline HTML events. They muddy up your HTML code and make it harder to manage your scripting.

Instead, place the script just before the </body> tag.


<script type="text/javascript" src="js/script.js"></script>
</body>

With the HTML code, you really should use an actual submit button, so that your page can work even when no scripting is available.

Despite that though, all you need in the HTML code is to place an identifier on the form tag.


<form id="sendInvoice" method="..." action="...">

In the js/script.js script, use this code to capture and work with the form’s submit event.


document.getElementById('sendInvoice').onsubmit = function () {
    return window.prompt('Are you sure you want to send these');
}

When the person chooses [Cancel] then false will be returned, which prevents the form from being submitted. When the person choose [OK] the form will be sent.