Microsoft
Software
Hardware
Network
Question : Javascript date calculation -- year isn't changing
I have two dates below, the 2nd is supposed to set the date to 6 months out, and change the year as well if it falls into the next year. It seems to be calculating month and date correctly, but the year still says 2010. How do I get the year to adjust automatically?
<html>
<head>
<script defer>
var dteDate = new Date();
var dteMonth = dteDate.getMonth() + 1;
var dteDay = dteDate.getDate();
var dteYear = dteDate.getYear();
var dte6Months = dteDate.getMonth() + 7;
dteDate.setMonth(dteDate.g
etMonth() + 8);
document.EntryForm.oppo_pr
ojectstart
date.value
= dteMonth + '/' + dteDay + '/' + dteYear;
document.EntryForm.oppo_pr
ojectinsta
lldate.val
ue = dteDate.getMonth() + '/' + dteDay + '/' + dteYear;
</script>
</head>
<body>
<form name=EntryForm>
<input type=text name=oppo_projectstartdate
>
<br>
<input type=text name=oppo_projectinstallda
te>
</form>
</body>
</html>
Answer : Javascript date calculation -- year isn't changing
document.EntryForm.oppo_pr
ojectstart
date.value
= dteMonth + '/' + dteDay + '/' + dteYear;
document.EntryForm
.oppo_proj
ectinstall
date.value
= dteDate.getMonth() + '/' +
dteDate.getDate()
+ '/' +
dteDate.getFullYear()
;
Random Solutions
Tomcat Webapps Read File
Quicktime Movie not visible in some browsers?
Vodafone Mobile Connect Error Code 619
asp.net Need to know to reset a form. once it has been submited. My form is retaining it values.
mailto hyperlink with multiple links on multiple lines
Firefox displays vertical scroll - IE doesn't
Using SBS to to link together 7 remotes sites with 1 central administration office?
Script that check 2 colums in 2 sheets and hyperlinks. Need a way to check exact match and hyperlink.
.net generic collection vs hashtable
Server folder syncing software that has a scheduler and hosts multiple targets