document.myForm.submit();
window.dialogArguments.close();
dialogArguments.close()
line is getting executed first and document.myForm.submit()
line is getting executed last.
How can we stop the interpeter to execute other lines of code until substitution done?
You should not prevent any part of code. Just need put your code in right place.
For example:
function deleteDocument(form) {
if (confirm("Do you really want to delete the document?"))
form.submit();
window.dialogArguments.close();
}
<form action="deleteDocument.php" onsubmit="deleteDocument(this);return false;">
</form>
Try like
document.myForm.submit();
setTimeout(
function() {
window.dialogArguments.close(); },
500);
Set time out for delay execute for function. or Use as callback function to window.dialogArguments.close() ;
<form onsubmit="do_something()">
function do_something(){
// Do your stuff here
}
If you put return like the code below, you can prevent the form submission by returning false from the do_something() function.
<form onsubmit="return do_something()">
function do_something(){
// Do your stuff here
return true; // submit the form
return false; // don't submit the form
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.