JSP/Example2011.10.07 17:45
각 달에 따라 날짜가 다른 것을 자동으로 맞춰주는 스크립트 코드
2월달이 되면 날짜 선택이 28일로 변경되고, 윤년시 29일이 되는 것도 적용 되어 있음.

미리보기.
[##_1N_##]


 
다음은 이에 관련된 소스.
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page language="java" import="java.util.*" %>      




날짜
<script language="javascript">  
	function onlastday(setid){
		selectYear = document.getElementById("year"+setid);
	    selectMonth = document.getElementById("month"+setid);
	    selectDay = document.getElementById("day"+setid);	  
	   	    
	    setYear = selectYear.options[selectYear.selectedIndex].value;
	    setMonth = parseInt(selectMonth.options[selectMonth.selectedIndex].value) + 1;
	    
	    tmpDate = new Date(setYear, setMonth, 0);	    
	    selectedIndex = selectDay.selectedIndex;	   
		selectDay.length = 0;
	    for(i = 0; i < tmpDate.getDate(); i++) {		     
		     selectDay.options[i] = new Option(i+1, i+1);
		    }
	   
	    if(selectedIndex <= tmpDate.getDate()) {
		     selectDay.options[selectedIndex].selected = true;
		    } else {
		     selectDay.options[tmpDate.getDate()-1].selected = true;
		    }
	    
		}
</script> 
<body>  

<%	
	GregorianCalendar today = new GregorianCalendar();
	int nowYear = today.get(today.YEAR);
	int nowMonth = today.get(today.MONTH)-1;
	int nowDay = today.get(today.DAY_OF_MONTH);
	int lastDay= today.getActualMaximum ( Calendar.DAY_OF_MONTH );		
%>
<center> 

<form method="post" name=serch action="call_log.do"> 
<table cellspacing="0" border="0" class="tbl_type" aline="center">

<tr>
<td colspan="2">

시
 ~  


</td>
</tr>
</table>
</form> 

</center> 

</body> 
Posted by 하품 - yawn 하품 - yawn

댓글을 달아 주세요