My college is organising a coding competition and for that we were tasked to build an interface which will be used on the localhost. We have achieved almost everything except one thing - auto submitting a user's answer when the timer ends. The code for the javascript is given below..
<script>
window.onload = counter ;
function counter ()
{
var minutes = 29;
var seconds = 60 ;
countDown ();
function countDown ()
{
document.getElementById("mins").innerHTML = minutes ;
document.getElementById("secs").innerHTML = seconds ;
if ( seconds>0 )
{
seconds= seconds - 1 ;
setTimeout (countDown ,1000 );
}
result();
function result ()
{
if ( seconds == 0 )
{
if (minutes > 0)
{
minutes = minutes -1;
seconds = 60;
countdown();
}
if(minutes == 0 && seconds == 0)
{
var a = parseInt(prompt("Your time is up, please contact your co-ordinators"));
if (a==111)
{
//document.write("Submit the form");
}
else{
prompt("Your time is up, please contact your co-ordinators");
result();
}
}
}
}
}
}
</script>
How to add auto submit coding in it so that it will automatically submit user's answer.