I have made a quiz website and set a timer using javascript. The content of the form is updated and submitted when submit button isset. How do i make the button set using javascript or how can i just add some condition when the timer hits zero which can be verified in PHP if condition
This is the javascript code
<script type="text/javascript">
var total_seconds = 3*1;
var c_minutes = parseInt(total_seconds/60);
var c_seconds = parseInt(total_seconds%60);
function CheckTime(){
document.getElementById("quiz-time-left").innerHTML = 'Time Left: ' + c_minutes + ' minutes ' + c_seconds + ' seconds ' ;
**if(total_seconds <=0){
document.getElementById("register_btn").readOnly = false;**
} else {
total_seconds = total_seconds -1;
c_minutes = parseInt(total_seconds/60);
c_seconds = parseInt(total_seconds%60);
setTimeout("CheckTime()",1000);
}
}
setTimeout("CheckTime()",1000);
</script>
This is the HTML form
<form method="post" name="quiz" action="quiz.php" class="myform" id="quiz">
<input type="submit" id="register_btn" value="Submit Answer" name="submit_ans">
</form>
This is the PHP code
<?php
if(isset($_POST['submit_ans'])){updating database and condition}
?>
What shall i write in the javascript if condition so that the isset condition in PHP is satisfied. If there is any other alternative for the same please help.