날짜 select 의 option 쉽게 설정하기 > 기술자료 | 해피정닷컴

날짜 select 의 option 쉽게 설정하기 > 기술자료

본문 바로가기

사이트 내 전체검색

날짜 select 의 option 쉽게 설정하기 > 기술자료

ClassicASP 날짜 select 의 option 쉽게 설정하기

페이지 정보


본문

form 문에서 select 로 년/월/일 선택하는 창 만들때 현재 날짜 기준으로 선택되도록 할때 불편하죠,
그것을 for 문으로 이용해서 간단히 해결하는 로직입니다.

[ 방법 1]

<% Option Explicit %>
<% dim i %>

<select name="r_year" size="1" style="font-size:9pt;">
    <% for i = year(now) to 2005 step -1 %>
  <option value="<% response.write i %>" <% if year(date) = i then %> selected <% end if %>><% response.write i %></option>
  <% next %>
</select>년 

<select name="r_month" size="1" style="font-size:9pt;">  
    <% for i = 1 to 12 step 1 %>
    <option value="<% response.write i %>" <% if month(date) = i then %> selected <% end if %>><% response.write i %></option>
    <% next %>      
</select>월 

<select name="r_day" size="1" style="font-size:9pt;">  
  <% for i = 1 to 31%>
  <option value="<% response.write i %>" <% if day(date) = i then %> selected <%end if%>><% response.write i %></option>
  <% next %>        
</select>일


[ 방법 2]

  <select name="r_year">
    <option value="2006">2006</option>
    <option value="2007">2007</option>
  </select>년
  <select name="r_month">
    <%
      for i = 1 to 12
      response.write "<option value='" & i & "'"
      if i = Month(now) then
        response.write "selected"
      end if
      response.write ">" & i & "</option>"
      next
    %>
  </select>월
  <select name="r_day">
    <%
      for i = 1 to 31
      response.write "<option value='" & i & "'"
      if i = day(now) then
      response.write "selected"
      end if
      response.write ">" & i & "</option>"
      next
    %>
    </select>일

댓글목록

등록된 댓글이 없습니다.


Total 21건 1 페이지
  • RSS
기술자료 목록
21
그누보드   5065  2021-08-31 18:52  
20
그누보드   4924  2021-02-25 22:28 ~ 2021-03-17 11:33  
19
MySQL   11802  2019-09-09 20:18  
18
MySQL   8993  2019-01-22 00:43  
17
HTML   6699  2018-11-16 12:11 ~ 2018-11-16 12:17  
16
그누보드   10502  2018-01-19 14:37  
15
MSSQL   9387  2017-12-05 23:56 ~ 2017-12-05 23:58  
14
Java   23541  2017-04-02 15:44  
13
그누보드   37422  2014-04-13 14:57  
12
Adobe   36941  2013-03-23 17:25 ~ 2013-03-23 00:00  
11
JavaScript   18483  2013-01-14 20:23  
10
HTML   24968  2012-10-20 21:42  
열람
ClassicASP   15543  2012-04-18 13:41 ~ 2016-03-30 00:00  
8
ClassicASP   12844  2012-01-14 23:08 ~ 2014-01-13 00:00  
7
MySQL   13402  2009-12-09 22:32  
6
MSSQL   41507  2009-07-27 07:28  
5
HTML   16043  2009-01-04 03:51  
4
MSSQL   21593  2008-11-27 14:21  
3
PHP   22581  2008-04-26 15:59 ~ 2013-01-14 00:00  
2
JavaScript   23448  2006-11-08 21:33 ~ 2018-04-12 17:28  

검색

해피정닷컴 정보

회사소개 회사연혁 협력사 오시는길 서비스 이용약관 개인정보 처리방침

회사명: 해피정닷컴   대표: 정창용   전화: 070-7600-3500   팩스: 042-670-8272
주소: (34368) 대전시 대덕구 대화로 160 대전산업용재유통단지 1동 222호
개인정보보호책임자: 정창용   사업자번호: 119-05-36414
통신판매업신고: 제2024-대전대덕-0405호 [사업자등록확인]  
Copyright 2001~2025 해피정닷컴. All Rights Reserved.