87,922
社区成员
发帖
与我相关
我的任务
分享
<script>
document.write("<select id='et'>");
var year =2008;
var month =1;
var month1=1;
for(var i=0;i<90;i++){
if(month>12){
year++;
month=1;
var str_temp=month.toString();
month="0"+str_temp;
}else if(month<10){
var str_temp=month.toString();
month="0"+str_temp;
}
// if(month1>12){
// year++;
// month1=1;
// month1=month+1;
// var str_temp1=month1.toString();
// month1="0"+str_temp1;
// }else if(month1<10){
// var str_temp1=month1.toString();
// month1="0"+str_temp1;
// }
// var datestr1 = year+"-"+month1;
var datestr = year+"-"+month;
document.write("<option value="+datestr+'-01'+">"+datestr+"</option>");
month++;
}
document.write("</select>");
document.getElementById('et').options[73].selected="selected";
</script>
var value = (parseInt(split[1]) + 1) > 12 ? (parseInt(split[0]) + 1) + "-01" : (parseInt(split[1]) + 1) < 10 ? split[0] + "-0"+(parseInt(split[1]) + 1) : split[0] + "-"+(parseInt(split[1]) + 1);
[/quote]
为什么喜欢+-1呢 他这边不是用Date搞出来的月份 month不会比实际的小一呢
var value = (parseInt(split[1]) )> 12 ? (parseInt(split[0]) + 1) + "-01" : (parseInt(split[1]) ) < 10 ? split[0] + "-0"+(parseInt(split[1]) + 1) : split[0] + "-"+(parseInt(split[1]) + 1);[/quote]
错了 应该是var value = (parseInt(split[1]) )> 12 ? (parseInt(split[0]) + 1) + "-01" : (parseInt(split[1])+1 ) < 10 ? split[0] + "-0"+(parseInt(split[1])+1 ) : split[0] + "-"+(parseInt(split[1]) + 1);
[/quote]
鹅鹅鹅 脑子不清楚。。 。 你是对的= = sorryvar value = (parseInt(split[1]) + 1) > 12 ? (parseInt(split[0]) + 1) + "-01" : (parseInt(split[1]) + 1) < 10 ? split[0] + "-0"+(parseInt(split[1]) + 1) : split[0] + "-"+(parseInt(split[1]) + 1);
[/quote]
为什么喜欢+-1呢 他这边不是用Date搞出来的月份 month不会比实际的小一呢
var value = (parseInt(split[1]) )> 12 ? (parseInt(split[0]) + 1) + "-01" : (parseInt(split[1]) ) < 10 ? split[0] + "-0"+(parseInt(split[1]) + 1) : split[0] + "-"+(parseInt(split[1]) + 1);[/quote]
错了 应该是var value = (parseInt(split[1]) )> 12 ? (parseInt(split[0]) + 1) + "-01" : (parseInt(split[1])+1 ) < 10 ? split[0] + "-0"+(parseInt(split[1])+1 ) : split[0] + "-"+(parseInt(split[1]) + 1);
var value = (parseInt(split[1]) + 1) > 12 ? (parseInt(split[0]) + 1) + "-01" : (parseInt(split[1]) + 1) < 10 ? split[0] + "-0"+(parseInt(split[1]) + 1) : split[0] + "-"+(parseInt(split[1]) + 1);
[/quote]
为什么喜欢+-1呢 他这边不是用Date搞出来的月份 month不会比实际的小一呢
var value = (parseInt(split[1]) )> 12 ? (parseInt(split[0]) + 1) + "-01" : (parseInt(split[1]) ) < 10 ? split[0] + "-0"+(parseInt(split[1]) + 1) : split[0] + "-"+(parseInt(split[1]) + 1);var value = (parseInt(split[1]) + 1) > 12 ? (parseInt(split[0]) + 1) + "-01" : (parseInt(split[1]) + 1) < 10 ? split[0] + "-0"+(parseInt(split[1]) + 1) : split[0] + "-"+(parseInt(split[1]) + 1);
document.write("<select id='et'>");
var year =2008;
var month =1;
for(var i=0;i<90;i++){
if(month>12){
year++;
month=1;
var str_temp=month.toString();
month="0"+str_temp;
}else if(month<10){
var str_temp=month.toString();
month="0"+str_temp;
}
var datestr = year+"-"+month;
var split = datestr.split('-');
var value = (parseInt(split[1]) - 1) < 1 ? (parseInt(split[0]) - 1) + "-12" : (parseInt(split[1]) - 1) < 10 ? split[0] + "-0"+(parseInt(split[1]) - 1) : split[0] + "-"+(parseInt(split[1]) - 1);
document.write("<option value="+value+">"+datestr+"</option>");
month++;
}
document.write("</select>");
document.getElementById('et').options[73].selected="selected";