首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

根据实际天数生成时间上拉列表

2012-11-22 
根据实际天数生成时间下拉列表//初始化下拉列表function initSelectTime(dateNum,sysTime){var rideDate

根据实际天数生成时间下拉列表

//初始化下拉列表function initSelectTime(dateNum,sysTime){var rideDate = document.getElementById("rideDate");$("currentTime").innerText=sysTime;//今天var   todayStr = sysTime.substring(0,10);    var today = new Date(todayStr.replace(/-/g,"\/"));    var tempOption = document.createElement("option");rideDate.options.add(tempOption);tempOption.text = "今天 "+today.getFullYear()+"-"+checkTime(today.getMonth()+1)+"-"+checkTime(today.getDate())+" "+getDayOfWeek(today.getFullYear()+"-"+(today.getMonth()+1)+"-"+today.getDate());       tempOption.value = today.getFullYear()+"-"+checkTime(today.getMonth()+1)+"-"+checkTime(today.getDate());    tempOption.selected = "selected";    if(dateNum>2){for(var i=2;i<=dateNum;i++){var   t = today.getTime() + 24*3600*1000*(i-1);       var   temDate   =   new  Date(t);       var tempOption = document.createElement("option");rideDate.options.add(tempOption);var optionText = temDate.getFullYear()+"-"+checkTime(temDate.getMonth()+1)+"-"+checkTime(temDate.getDate())+" "+getDayOfWeek(temDate.getFullYear()+"-"+(temDate.getMonth()+1)+"-"+temDate.getDate());if(i==2){tempOption.text = "明天 "+optionText;}else if(i==3){tempOption.text = "后天 "+optionText;}else{tempOption.text = "           "+optionText;}    tempOption.value = temDate.getFullYear()+"-"+checkTime(temDate.getMonth()+1)+"-"+checkTime(temDate.getDate());}}}//根据日期得到星期function getDayOfWeek(dayValue){      //var dayValue = obj.value;      var day = new Date(Date.parse(dayValue.replace(/-/g, '/'))); //将日期值格式化      var today = new Array("周日","周一","周二","周三","周四","周五","周六");      var week =  today[day.getDay()]; //day.getDay();根据Date返一个星期中的某其中0为星期日      return week;   }

?

?

热点排行