Answered by:
Submit all the question when time is out

Question
-
User1694748171 posted
I tried to submit all question when timer is out by calling the button type submit but its not working, any idea'
<div id="hms" class="hms" hidden="hidden">"01:30:00"</div> <div id="countTime" hidden="hidden"></div> <script type="text/javascript"> // localStorage.removeItem("counter"); var startTime = document.getElementById('hms').innerHTML; if (localStorage.getItem("counter")) { if (getjudgetime(localStorage.getItem("counter"))) { var value = startTime; } else { var value = localStorage.getItem("counter"); } } else { var value = startTime; } document.getElementById('countTime').innerHTML = value; var counter = function () { if (getjudgetime(value)) { localStorage.setItem("counter", startTime); value = startTime; } else { value = getnewtimestring(value); localStorage.setItem("counter", value); } document.getElementById('countTime').innerHTML = value; }; var interval = setInterval(counter, 1000); function getnewtimestring(oTime) { var timedif = new Date(getnewtime(oTime).valueOf() - 1000); var newtime = timedif.toTimeString().split(" ")[0]; return newtime; } function getnewtime(oTime) { var pieces = oTime.split(":"); var time = new Date(); time.setHours(pieces[0]); time.setMinutes(pieces[1]); time.setSeconds(pieces[2]); return time; } function getjudgetime(jTime) { if (getnewtime(jTime) <= getnewtime("00:00:00")) { localStorage.removeItem("counter"); ('#timeout').submit(); alert(); } return getnewtime(jTime) <= getnewtime("00:00:00") ? true : false } </script>
and here mu buttom that should be called when timer is "00:00:00"
<div class="text-center form-group col-md-12 "> <button id="btnSave" type="submit" onclick="validateAndSubmit();" class=" btn btn-primary"> FINISHED </button> <button id="btnSave1" type="submit" hidden="hidden" class=" btn btn-primary"> FINISHED </button> </div> <div> <button id="timeout" type="button" class="btn btn-primary small" hidden="hidden" onclick="location.href = '@Url.Action("Index", "Student_Exam", new { } )'"> <i class="fa fa-plus-circle"></i> FINISHED </button> </div>
Thursday, August 6, 2020 3:43 PM
Answers
-
User475983607 posted
Just submit the form.
document.getElementById("myForm").submit();
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, August 6, 2020 3:45 PM
All replies
-
User475983607 posted
Just submit the form.
document.getElementById("myForm").submit();
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, August 6, 2020 3:45 PM -
User1694748171 posted
Thank your for your help. and i have another question when time is out how I can reset the timer to 00:00:00 on the web page. in my case when time is up instead of showing me 00;00;00 it show 23:59:59 and time is stop .
any idea
Thursday, August 6, 2020 7:40 PM