469,271 Members | 1,544 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

Need to change year

155 100+
Hey,

I have this code that displays a default year and and from a drop down menu 15 additional years from the default year.

The default year is 2000. I'd like to change it to the current year (2008) if it's possible and the fifteen additional years start from 2008.

Thanks.

[PHP] output += '</select> \n<select id="year">\n';
for(var i=0;i<=15;i++) {
n = (i<10)? '0'+i:i;
output += '<option value="20'+n+'">20'+n+' </option>\n';
}
output += '</select> <a href="javascript:jumpTo()"><img src="/calendar/images/calGo.gif" alt="go" />Go</a> <a href="javascript:hideJump()"><img src="/calendar/images/calStop.gif" alt="close" />Close</a>';
jump.innerHTML = output;
document.body.appendChild(jump);
}
[/PHP]
Feb 25 '08 #1
2 1248
DavidPr
155 100+
OK got it.

[PHP]output += '</select> \n<select id="year">\n';
for(var i=8;i<=23;i++) {
n = (i<10)? '0'+i:i;
output += '<option value="20'+n+'">20'+n+' </option>\n';
}
output += '</select> <a href="javascript:jumpTo()"><img src="/calendar/images/calGo.gif" alt="go" />Go</a> <a href="javascript:hideJump()"><img src="/calendar/images/calStop.gif" alt="close" />Close</a>';
jump.innerHTML = output;
document.body.appendChild(jump);
}[/PHP]
Thanks
Feb 26 '08 #2
acoder
16,027 Expert Mod 8TB
Instead of that, get the current year automatically, so you don't have to keep changing the code each year.
Feb 26 '08 #3

Post your reply

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

Similar topics

7 posts views Thread by Keyed4U | last post: by
8 posts views Thread by Shlomi Schwartz | last post: by
2 posts views Thread by Mike Button | last post: by
3 posts views Thread by charliewest | last post: by
3 posts views Thread by mistral | last post: by
15 posts views Thread by rhino | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.