- Home
- Categorie
- Coding e Sistemistica
- Coding
- Stampare messaggio al termine del countdown javascript
-
Stampare messaggio al termine del countdown javascript
Salve avrei bisogno di un aiutino per comprendere come stampare un messaggio del tipo " Annuncio terminato" al termine di un countdown in javascript.
Di seguito posto il codice dello script:<!--Countdown Timer starts here--> <script type="text/javascript"> // Description: displays the amount of time until the "dateFuture" entered below. // NOTE: the month entered must be one less than current month. ie; 0=January, 11=December // NOTE: the hour is in 24 hour format. 0=12am, 15=3pm etc // format: dateFuture = new Date(year,month-1,day,hour,min,sec) // example: dateFuture = new Date(2003,03,26,14,15,00) = April 26, 2003 - 2:15:00 pm dateFuture = new Date('<?php echo $coopen_timer[0]; ?>','<?php echo ($coopen_timer[1] - 1) ; ?>','<?php echo $coopen_timer1[0]; ?>','<?php echo $coopen_timer3[0]; ?>','<?php echo $coopen_timer3[1]; ?>','<?php echo $coopen_timer3[2]; ?>'); //alert(dateFuture); function GetCount(){ dateNow = new Date(); //grab current date amount = dateFuture.getTime() - dateNow.getTime(); //calc milliseconds between dates delete dateNow; days=0;hours=0;mins=0;secs=0;nodays="";nohrs="";nomins=""; amount = Math.floor(amount/1000);//kill the "milliseconds" so just secs days=Math.floor(amount/86400);//days amount=amount%86400; hours=Math.floor(amount/3600);//hours amount=amount%3600; mins=Math.floor(amount/60);//minutes amount=amount%60; secs=Math.floor(amount);//seconds if(days != 0) { nodays = days +((days!=1)?"":""); //alert(nodays); document.getElementById('tot_days').innerHTML=nodays; } else { document.getElementById('tot_days').innerHTML=''; document.getElementById('days').innerHTML=''; } if(days != 0 || hours != 0) { nohrs = hours +((hours!=1)?"":""); //alert(nohrs); document.getElementById('tot_hrs').innerHTML=nohrs; } else { document.getElementById('tot_hrs').innerHTML=''; document.getElementById('hrs').innerHTML=''; } if(days != 0 || hours != 0 || mins != 0) { nomins = mins +((mins!=1)?"":""); //alert(nomins); document.getElementById('tot_mins').innerHTML=nomins; } else { document.getElementById('tot_mins').innerHTML=''; document.getElementById('mins').innerHTML=''; } document.getElementById('tot_secs').innerHTML = secs; setTimeout("GetCount()", 1000); } window.onload=GetCount;//call when everything has loaded </script> <!--Countdown Timer ends here-->
-
Volendo potresti aavere un div con all'interno la scritta "EVENTO TERMINATO".
Di default il display è settato a none.
Appena invece il tempo è terminato, il display viene settato a block.
-
Ciao e grazie per la risposta.
Sono poco esperto potresti postarmi un codice di esenpio e dove inserirlo?
Grazie
-
Per la terminazione dell'evento va bene una certa data? A una certa ora?