PDA

View Full Version : confirm / alert confilict



crobinson42
09-05-2010, 05:34 AM
i have a form on my page and the submit button calls this function:
function confirmSubmit()
{
var agree=confirm("Are you sure your report is complete?");
if (agree)
return true ;
else
return false ;
}

I also have on the page an alert if the user tries to navigate away this alert is brought up:
function goodbye(e) {
if(!e) e = window.event;
//e.cancelBubble is supported by IE - this will kill the bubbling process.
e.cancelBubble = true;
e.returnValue = '***YOU HAVE NOT SAVED YOUR REPORT***'; //This is displayed on the dialog

//e.stopPropagation works in Firefox.
if (e.stopPropagation) {
e.stopPropagation();
e.preventDefault();
}
}
window.onbeforeunload=goodbye;

The problem that has been brought to my attention is, if the user is submitting the form, both alert come up.

I would like to cancel out the 'function goodbye(e)' IF the user is hitting the submit button on the form and only have the first alert pop up.

Any help is much appreciated!