Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getMonth not working 1

Status
Not open for further replies.

simon551

IS-IT--Management
May 4, 2005
249
Code:
	var projMonth="Month";
	if (! (document.getElementById('projEndDate').value==''))
		{
			var enteredDate=document.getElementById('projEndDate');
			var endDate=new Date(enteredDate);
			var month=new Array(12);
			month[0]="Jan";
			month[1]="Feb";
			month[2]="March";
			month[3]="April";
			month[4]="May";
			month[5]="June";
			month[6]="July";
			month[7]="Aug";
			month[8]="Sept";
			month[9]="Oct";
			month[10]="Nov";
			month[11]="Dec";
			var projMonth= month[endDate.getMonth()];
		}

no matter what I enter in the projEndDate field it returns projMonth with a value of 'undefined'... do you see something I'm doing wrong here?
 
A simple mistake, one I've made many times before:
Code:
    var projMonth="Month";
    if (! (document.getElementById('projEndDate').value==''))
        {
            var enteredDate=document.getElementById('projEndDate')[!].value[/!];
            var endDate=new Date(enteredDate);
            var month=new Array(12);
            month[0]="Jan";
            month[1]="Feb";
            month[2]="March";
            month[3]="April";
            month[4]="May";
            month[5]="June";
            month[6]="July";
            month[7]="Aug";
            month[8]="Sept";
            month[9]="Oct";
            month[10]="Nov";
            month[11]="Dec";
            var projMonth= month[endDate.getMonth()];
        }

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson

[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top