function was working, now nothing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mdaniel1
    New Member
    • May 2012
    • 1

    function was working, now nothing

    I finished a button click function that would alert with the time and date, it was working. I saved, closed notepad+, came back later and now when I click nothing, no error codes at the bottom, nothing, no response.
    the button click is
    Code:
    onclick="ShowDate()"
    the function is
    Code:
    function ShowDate() {
     var thetime = new Date();
     var weekday = thetime.getDay();
     var themonth = thetime.getMonth();
     var thedate = thetime.getDate();
     var theyear = thetime.getFullYear();
     var hour = thetime.getHours();
     var minutes = thetime.getMinutes();
     var seconds = thetime.getSeconds();
     var ap = (hour >= 12) ? 'p.m.' : 'a.m.';
     var someday = new Array(7);
     someday[0]="Sunday";
     someday[1]="Monday";
     someday[2]="Tuesday";
     someday[3]="Wednesday";
     someday[4]="Thursday";
     someday[5]="Friday";
     someday[6]="Saturday";
     var somemonth = new Array(12);
     somemonth[0]="January";
     somemonth[1]="February";
     somemonth[2]="March";
     somemonth[3]="April";
     somemonth[4]="May";
     somemonth[5]="June";
     somemonth[6]="July";
     somemonth[7]="August";
     somemonth[8]="September";
     somemonth[9]="October";
     somemonth[10]="November";
     somemonth[11]="December";
      
     if (hour < 1) {
       hour = 12;
       }
     if(minutes < 10){
       minutes = "0" + minutes;
       }
     if(seconds < 10){
       seconds = "0" + seconds;
       } 
     if(hour > 5&&hour < 12) {
       window.alert('Good Morning! Today is '+someday[weekday]+', '+somemonth[themonth]+' '+thedate+', '+theyear+'. The time is '+hour+':'+minutes+':'+seconds);
       }
     if(hour > 12&&hour < 19) {
       window.alert('Good afternoon! Today is '+someday[weekday]+', '+somemonth[themonth]+' '+thedate+', '+theyear+'. The time is '+hour+':'+minutes+':'+seconds);
       } 
     if(hour > 19&&hour < 5) {
       window.alert('Good Evening! Today is '+someday[weekday]+', '+somemonth[themonth]+' '+thedate+', '+theyear+'. The time is '+hour+':'+minutes+':'+seconds);
       }
     }
    thanks
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Your code will only work from 6 - 11 and 13 - 18 o'clock.

    Comment

    Working...