I am working on a web application which contains forms. I want to auto submit the forms if the user started to complete it but left and then got disconnected from his session.
I already have a JS alert after 15 minutes asking is user wants to submit the form or not. Then if the user doesn't answer, I want to auto submit. But the problem is that an alert box stops the code running. I tried with the line "setTimeout(function(){ submitform() }, 60000);" to auto submit after 1 minute but it obviously doesn't work.
function submitform(){
document.forms["form_pat_bvl"].submit();
}
function confirmAction() {
let confirmAction = confirm("Would you like to submit ?");
if (confirmAction) {
submitform();
}
setTimeout(function(){ submitform() }, 60000);
}
I also tried with "<META HTTP-EQUIV="Refresh" CONTENT="60;url=../servlet/mypage">" but it only works for the doGet method wheras my servlet uses the doPost method.
I don't know if my ideas are good, I have been asked to do this way by asking user first if he wants to submit and then submit for him if he doesn't answer... but I really don't know how to save his form if he's inactive after an alert.
Thank you in advance !