본문 바로가기
IT관련/JSP

[JSP] 생년월일 옵션(for문)

by 확고 2022. 3. 31.
728x90
반응형

생년월일 옵션(for문)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<select name="year">
<%
     for(int i=2022;i>=1930;i--){ //2022~1930년까지
%>
    <option value="<%= i %>" <%if(i == sb.getYear()){ %> selected <% } %> ><%= i %></option>
<%
     }//for
%>
</select> 년
 
 
<select name="month">
<%
     for(int i = 1 ; i<=12 ; i++){
%>
    <option value="<%=i %>" <%if(i==sb.getMonth()){%> selected <%}%>><%=i %></option>
<%
     }
%>
</select> 월
 
 
 
 
<select name="day">
<%
     for(int i=1;i<=31;i++){
%>
    <option value="<%=i %>" <%if(i==sb.getDay()){%>selected<%}%>><%=i %></option>
<%
     }
%>
</select> 일
cs

728x90
반응형

댓글