473,387 Members | 1,583 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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
Expand|Select|Wrap|Line Numbers
  1. onclick="ShowDate()"
the function is
Expand|Select|Wrap|Line Numbers
  1. function ShowDate() {
  2.  var thetime = new Date();
  3.  var weekday = thetime.getDay();
  4.  var themonth = thetime.getMonth();
  5.  var thedate = thetime.getDate();
  6.  var theyear = thetime.getFullYear();
  7.  var hour = thetime.getHours();
  8.  var minutes = thetime.getMinutes();
  9.  var seconds = thetime.getSeconds();
  10.  var ap = (hour >= 12) ? 'p.m.' : 'a.m.';
  11.  var someday = new Array(7);
  12.  someday[0]="Sunday";
  13.  someday[1]="Monday";
  14.  someday[2]="Tuesday";
  15.  someday[3]="Wednesday";
  16.  someday[4]="Thursday";
  17.  someday[5]="Friday";
  18.  someday[6]="Saturday";
  19.  var somemonth = new Array(12);
  20.  somemonth[0]="January";
  21.  somemonth[1]="February";
  22.  somemonth[2]="March";
  23.  somemonth[3]="April";
  24.  somemonth[4]="May";
  25.  somemonth[5]="June";
  26.  somemonth[6]="July";
  27.  somemonth[7]="August";
  28.  somemonth[8]="September";
  29.  somemonth[9]="October";
  30.  somemonth[10]="November";
  31.  somemonth[11]="December";
  32.  
  33.  if (hour < 1) {
  34.    hour = 12;
  35.    }
  36.  if(minutes < 10){
  37.    minutes = "0" + minutes;
  38.    }
  39.  if(seconds < 10){
  40.    seconds = "0" + seconds;
  41.    } 
  42.  if(hour > 5&&hour < 12) {
  43.    window.alert('Good Morning! Today is '+someday[weekday]+', '+somemonth[themonth]+' '+thedate+', '+theyear+'. The time is '+hour+':'+minutes+':'+seconds);
  44.    }
  45.  if(hour > 12&&hour < 19) {
  46.    window.alert('Good afternoon! Today is '+someday[weekday]+', '+somemonth[themonth]+' '+thedate+', '+theyear+'. The time is '+hour+':'+minutes+':'+seconds);
  47.    } 
  48.  if(hour > 19&&hour < 5) {
  49.    window.alert('Good Evening! Today is '+someday[weekday]+', '+somemonth[themonth]+' '+thedate+', '+theyear+'. The time is '+hour+':'+minutes+':'+seconds);
  50.    }
  51.  }
  52.  
thanks
May 2 '12 #1

✓ answered by Rabbit

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

1 1211
Rabbit
12,516 Expert Mod 8TB
Your code will only work from 6 - 11 and 13 - 18 o'clock.
May 3 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: knoak | last post by:
Hi there, I have a site with just a few pages. (e.g. home.php) In every page there is another page included with things like the header etc. The included file is in a subdirectory called...
4
by: Eric Lilja | last post by:
Hello, I've made a templated class Option (a child of the abstract base class OptionBase) that stores an option name (in the form someoption=) and the value belonging to that option. The value is...
1
by: tencip | last post by:
Hey everyone, We've got FreeBSD 5.3, with Sendmail running. All we want to do is to get sendmail to send emails to another server for actual outbound email. We've got a very basic php script...
1
by: JIM.H. | last post by:
Hello, I have this function working in one of my project. Can anyone convert this to C#? I used one of the converter but faced problems, it did not compile. Public Function...
1
by: tkkarthik | last post by:
Hello everyone.. Let me tell where i am in my programming.. I have 3 command buttons in my form. say a, b,c When I press the Key A in keyboard, I need the color of my command buton A to...
5
helimeef
by: helimeef | last post by:
Hi, I'm running Apache 2 and PHP 5.2.0 on Windows XP Media Center Edition. My problem is if I write a simple mail program like this: if(mail("__MUNGED__","Test Mail","This is a test message from...
3
by: dkyadav80 | last post by:
Hi sir, I'have written small function in javascript for date (month and year), this is good working in IE at onclick event and current month-8 , year-2008 are displaying but in firefox3,opera,&...
7
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I am using this code to get groups for a user and getting a error (5) on the GetAuthorizationGroups() function . There are two domains. This function works on the local domain but does not work...
4
johny10151981
by: johny10151981 | last post by:
/*name of the built program is dmns*/ int main() { int i, j; i=fork(); if(i<0) return 1; printf("created pid=%d",i); while(1) {i=i;} //unlimited loop
4
Thew
by: Thew | last post by:
<!DOCTYPE html> <html> <head> <title>Example</title> <meta http-equiv="Content-type" content="text/html;charset=UTF-8"> <script type="text/javascript"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.