how to form submit on timer/countdown you can pass time through in javascript CountDown(5,div); function, example 10 second pass CountDown(10,div);
Let's create a index.php file.
<html> <body> <form action="" method="post" name="MCQuestion" id="MCQuestion"> Name:<input type="test" name="name" value="ABC"> <div><span id="display" style="color:#FF0000;font-size:15px"></span></div> <div><span id="submitted" style="color:#FF0000;font-size:15px"></span></div> </form> <script> var div = document.getElementById('display'); var submitted = document.getElementById('submitted'); function CountDown(duration, display) { var timer = duration, minutes, seconds; var interVal= setInterval(function () { minutes = parseInt(timer / 60, 10); seconds = parseInt(timer % 60, 10); minutes = minutes < 10 ? "0" + minutes : minutes; seconds = seconds < 10 ? "0" + seconds : seconds; display.innerHTML ="<b>" + minutes + "m : " + seconds + "s" + "</b>"; if (timer > 0) { --timer; }else{ clearInterval(interVal) SubmitFunction(); } },1000); } function SubmitFunction(){ submitted.innerHTML="Time is up!"; document.getElementById('MCQuestion').submit(); } CountDown(5,div); </script> </body> </html>