例子:
function getDate(day){
var zdate=new Date();
var sdate=zdate.getTime()-(1*24*60*60*1000);
var edate=new Date(sdate-(day*24*60*60*1000)).format("yyyy-MM-dd");
return edate;
}
function changevalue(obj){
alert(obj);
var a = getDate(+7);
var b = getDate(+31);
if(obj=="8"){
document.getElementById("enddate").value=b;
}else{
document.getElementById("enddate").value=a;
}
}