실제 일수에 따라 시간 드롭다운 목록 생성

2232 단어 드롭다운 목록
// 
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;
   }

 

좋은 웹페이지 즐겨찾기