Pop up message when you press 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
any tips?

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

Thanks

<form action="..." onsubmit="return confirm('Are you sure you want to send?')">
  ...
  <input type="submit" value="Send Invoices &raquo;">
  ...
</form>

Thanks
but once I take this out

 onclick="document.checkmail.submit();">

it wont work for me

That’s because you have <input type="button">, not <input type="submit"> as in my example.

A generic button doesn’t do anything, but requires a JavaScript event handler. You shouldn’t require JavaScript just to submit the form.

A submit button, on the other hand, submits the form by default.

But when I use your code it doesnt do anything, (it just reloads the same page)
should I be putting something in the form action?

<form action=“…”

Yes - whatever you had there before to process the submitted form.

Yes, of course. The action attribute of a form is required, and should contain the URI of the script or application that is to receive the form submission. I used an ellipsis to indicate a placeholder, since the code snippet you posted didn’t contain the <form> tag and the action URI.

So now im using this:


<form name="search" method="post" action="dsp_searchdocs.cfm">

<td colspan="1" align="right"><input type="submit" value="Send Invoices &raquo;" OnSubmit= "return confirm ('Are You Sure you want to send?')"onclick="document.checkmail.submit();"></td>

</form 

But its still just reloading the same page, What am I doing wrong?

Im also trying to put in an extra piece of code to this, if no checkboxes are checked, to “Please make a selection before sending”

Thanks

You’ve put the onsubmit event handler on the <input> button. That won’t fly. It needs to go in the <form> tag, as indicated in my post above. You don’t submit a button. You submit the entire form.

Besides, your markup looks absolutely messed up! You can’t have a <td> as an immediate child of a form! It must have a <tr> parent. And you can’t wrap the table and the row around the form and put the cell inside the form.