473,425 Members | 1,974 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,425 software developers and data experts.

Month Date problem

Jim
I have been using the javascript below on a web page since last August to
show the "Site updated" month
minus a month, which has been very successful, but January is showing a
"undefined 2004" message.
Help much appreciated
Jim
var m=new Array(13);var n=new Date()

m[1]="Site updated January";m[2]="Site updated February";m[3]="Site updated
March";m[4]="Site updated April";m[5]="Site updated May";m[6]="Site updated
June";
m[7]="Site updated July";m[8]="Site updated August";m[9]="Site updated
September";m[10]="Site updated October";m[11]="Site updated
November";m[12]="Site updated December"
document.write(m[n.getMonth()+0]+" "+n.getFullYear())
Jul 17 '05 #1
2 3923
As of JDK version 1.1, replaced by Calendar.get(Calendar.MONTH).

"Jim" <ji*@internet.com> wrote in message
news:3f***********************@news.dial.pipex.com ...
I have been using the javascript below on a web page since last August to
show the "Site updated" month
minus a month, which has been very successful, but January is showing a
"undefined 2004" message.
Help much appreciated
Jim
var m=new Array(13);var n=new Date()

m[1]="Site updated January";m[2]="Site updated February";m[3]="Site updated March";m[4]="Site updated April";m[5]="Site updated May";m[6]="Site updated June";
m[7]="Site updated July";m[8]="Site updated August";m[9]="Site updated
September";m[10]="Site updated October";m[11]="Site updated
November";m[12]="Site updated December"
document.write(m[n.getMonth()+0]+" "+n.getFullYear())

Jul 17 '05 #2
It was caused when you invoked n.getMonth for January and got a
returned number 0, which means January. Then you saw a word
'undefined' extracted from an unassociated element m[0].

To solve the problem, just write as follow,

m[n.getMonth() - 1]

"Jim" <ji*@internet.com> wrote in message news:<3f***********************@news.dial.pipex.co m>...
I have been using the javascript below on a web page since last August to
show the "Site updated" month
minus a month, which has been very successful, but January is showing a
"undefined 2004" message.
Help much appreciated
Jim
var m=new Array(13);var n=new Date()

m[1]="Site updated January";m[2]="Site updated February";m[3]="Site updated
March";m[4]="Site updated April";m[5]="Site updated May";m[6]="Site updated
June";
m[7]="Site updated July";m[8]="Site updated August";m[9]="Site updated
September";m[10]="Site updated October";m[11]="Site updated
November";m[12]="Site updated December"
document.write(m[n.getMonth()+0]+" "+n.getFullYear())

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Jim | last post by:
I have been using the javascript below on a web page since last August to show the "Site updated" month only minus a month, which has been very successful, but January is showing a "undefined 2004"...
6
by: Hasanain F. Esmail | last post by:
Hi all, I sincerly thank you all in advance for your help to solve this problem. I have been trying to find a solution to this problem for sometime now but have failed. I am working on a...
6
by: Ante Perkovic | last post by:
Hi, How to declare datetime object and set it to my birthday, first or last day of this month or any other date. I can't find any examples in VS.NET help! BTW, what is the difference...
34
by: prosoft | last post by:
When I use Dim myDTFI As DateTimeFormatInfo = New CultureInfo("he-IL", True).DateTimeFormat Dim strhmon1 As String = (myDTFI.GetMonthName(hmon1)) MsgBox(strhmon1) I get the local name of the...
9
by: AideenWolf | last post by:
Windows XP - Access 2003 I've been researching this for about 3 weeks now and I'm no closer then when I started so any help you all give me will save my hair. I'm VERY new and learning as I go so...
22
by: Stan | last post by:
I am working with Access 2003 on a computer running XP. I am new at using Access. I have a Db with a date field stored as mm/dd/yyyy. I need a Query that will prompt for the month, ie. 6 for...
7
by: ajaydesai | last post by:
I have JavaScript code to dispaly two month calendar days at a time, but i have a problem both month that disaplay at a time have same days (for example May and June has same days, June and July have...
1
by: shiznaw | last post by:
Private Function rprtdate() Dim rprtdates As Date Dim 1mnth As Integer 1mnth= Month(Date) + Month(DateSerial(Year(Date), Month(Date) + 1, Day(Date))) Select Case Frame35.Value 'the following...
6
by: Nkhosinathie | last post by:
hello guys,i've started with classes and i've been given this program below to program and also i will post the source code if you need it.this program reads as folllows. create a class called...
5
by: =?Utf-8?B?bWFib25k?= | last post by:
Hi Using a month calendar control so that my user can select a start and end date for a range that will be used in a SQL query. Problem.....if user selects a date in one month and then scrolls...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.