How can I create a form that has a counter and store the information in bank

Asked

Viewed 295 times

0

I’d like some help. I’m trying to create a page that calculates how much time a person spends on some tasks that will be available in a form, then the person selects the task and click on start where he starts to calculate the time spent through a chronometer can pause and stop and that this information is stored in a bank so that later I can consult.

1 answer

0


Good afternoon, I built a script that tells time, pause, resume and to. When stopping sends the data to the file that will do the Insert in the bd

<script>
    var estado = true; //estado do cronometro
    var tempo = 0; //tempo atual

    setInterval("mostrar()", 1000);

    function mostrar(){
        if(estado) {
            tempo += 1;
        }
        document.getElementById("res").innerHTML = tempo+"s";
    }

    function play(botao){ //pausa e retoma a contagem
        if(estado) {
            estado = false;
            botao.value = "retomar";
        }
        else {
            estado = true;
            botao.value = "pausar";
        }
    }

    function salvar(){ //envia os segundos para a página que irá salvar o resultado;
        $("#res").load("salvar.php", {tempo:tempo}); //recebe $_POST['tempo'] na pagina com o insert
    }

</script>

<input type="button" value="pausar" onclick="play(this)"/>
<input type="button" value="pausar" onclick="salvar()"/>
<div id="res"></div>

Just to get an idea!

  • Thanks for the strength Paul

Browser other questions tagged

You are not signed in. Login or sign up in order to post.