Page 1 of 1

Display message to every minute in Javascript

Posted: 22 Jan 2022, 06:54
by JanMolendijk
Hello,
On eatch minute from the current hour I wanna have an message
I can not find out how to complete

Code: Select all

I hope to get something like this (code not working)

<script>
var day = new Date();
let hr = day.getHours();
let mn = day.getMinutes();
let se = day.getSeconds();

let st_hm = +hr.+mn;

if (st_hm == 7.40) document.write("40 <br>55555555 Geld moet Rollen") 
if (st_hm == 7.41) document.write("41 <br>55555555 Geld moet Rollen") 
if (st_hm == 7.42) document.write("42 <br>55555555 Geld moet Rollen") 
if (st_hm == 7.43) document.write("43 <br>55555555 Geld moet Rollen") 
if (st_hm == 7.44) document.write("44 <br>55555555 Geld moet Rollen") 
</script>
this example give an messange on eatch differen minte

Code: Select all

<SCRIPT LANGUAGE="JavaScript"> 
day = new Date() 
hr = day.getHours() 
mn = day.getMinutes() 
se = day.getSeconds() 

if (mn == 1) document.write("<br>1 <br>") 
if (mn == 2) document.write("<br>2 <br>") 
if (mn == 3) document.write("<br>3 <br>") 
if (mn == 4) document.write("<br>4 <br>") 
if (mn == 5) document.write("<br>5 <br>") 

</script>
this example give an messange on eatch differen second

Code: Select all

<SCRIPT LANGUAGE="JavaScript"> 
day = new Date() 
hr = day.getHours() 
mn = day.getMinutes() 
se = day.getSeconds() 

if (se == 1) document.write("<br>1  Wat gaat er gebeuren ?") 
if (se == 2) document.write("<br>2 Draag zorg voor voorraad") 
if (se == 3) document.write("<br>3 Geld moet Rollen") 

if (se == 4) document.write("4 <br> Geld moet Rollen") 
if (se == 5) document.write("5 <br> Geld moet Rollen") 
</script>

Display message to every minute in Javascript

Posted: 22 Jan 2022, 11:35
by MarPlo
If you only want to display a message to every minute, just use the setInterval() function. It calls a function repeatedly, over and over again, at specified time intervals.
See the following tutorial:
coursesweb.net/javascript/settimeout-setinterval_t