+ 2

Simple alarm Java script for testing help

I made the time to appear on the screen all right and such, but I created two field boxes (input) and a submit. I want to take these values ​​that the user types and compare it with the current date and time and when he gives the time he gives an alert just to test it function mostreHora() { var d = new Date(); var hora = d.getHours(); var min = d.getMinutes(); var sec = d.getSeconds(); var div = document.getElementById(“relogio”); div.innerHTML = "<h3>" + hora + ":" + min + ":" + sec + "</h3>"; function alarme(){ var horaAlarme = document.getElementById("hora").value; var minutoAlarme = document.getElementById("minuto").value; if (hora == horaAlarme && min == minutoAlarme && sec == 0) { alert("Alarme Tocando!!!"); } } setInterval(mostreHora, 1000);

15th Mar 2020, 2:22 PM
Sorrayla Araujo
Sorrayla Araujo - avatar
1 Antwort
+ 2
Your code is good but you made some mistakes 1> Close the function mostreHora with } 2>Call the function alarme() from mostreHora 3> define hora, min, sec all three without var keyword (they will become global) still problem go to this working demo https://code.sololearn.com/W10Hr9XzXXkc
16th Mar 2020, 3:14 AM
@HanuV9d
@HanuV9d - avatar