Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 72416

javascript: my code is supposed to begin a countdown from 60 but is no longer appearing in my container [closed]

$
0
0

Code is supposed to begin a countdown from 60. Not appearing.. the time remaining box appeared before but completely went away when I tried to do the countdown function.

var playing = false;
var score;
var action;
var timeremaining;

//If we click on the start/reset button
document.getElementById("startreset").onclick = function(){

    //If we are playing
    if(playing == true){

        location.reload(); //reload page

    }else{//If we are not playing

        //change mode to playing
        playing = true;

        //set score to 0
        score = 0;
        document.getElementById("scorevalue").innerHTML = score;

        //show countdown box
        document.getElementById("timeremaining").style.display = "block";
            timeremaining = 60;
            document.getElementById("timeremainingvalue").innerHTML = timeremaining;

        //change button to reset
        document.getElementById("startreset").innerHTML = " Reset";

        //start countdown
        startCountdown();
}

        //reload page



        //reduce time by one second in loop
            //time left?
                //Yes->continue
                //No->game over

        //generate new Q&A

//If we click on answer box
    //If we are playing
        //correct?
            //yes
                //increase score by one
                //show correct box
                //generate new Q&A
            //no
                //show try again box
}

function startCountdown(){
    action = setInterval(function(){
        timeremaining -= 1;
        document.getElementById("timeremainingvalue").innerHTML = timeremaining;
    }, 1000);
}
<div id='startreset'>click here</div><div id='timeremainingvalue'></div><div id='scorevalue'></div><div id='timeremaining'></div>

Viewing all articles
Browse latest Browse all 72416

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>