◆ 무한한 가능성/& ASP

[ASP] select option 동적으로 option 값 가져오기 - 연월일, 배열이용

치로로 2013. 8. 30. 00:46

/////////////////////////////////////////////////////////////////////////////

// - ※ 본 소스는 개인적인 용도로 작성 된 것이므로, 오류가 있을 수 있으니...

// - ...본 포스팅을 읽으시는 분들께서는 이 점 숙지 하시기 바랍니다. 감사합니다.

/////////////////////////////////////////////////////////////////////////////




<%

'=========================================================================== 동적으로 연월호 값 가져오기 - 시작

%>

<SCRIPT LANGUAGE="JavaScript">

<!--

function open_popup(val) {

window.open("/경로/test.asp","new","width=1000,height=800");

}

//-->

</SCRIPT>

<%

'&&&&&&&&&&&&&&&&&&& 변수 초기화 - 시작

Dim int_Month_Init, int_Month_Now, int_Month_Next, str_Result


int_Month_Init = 0 ' 초기화 월

int_Month_Now = Left(Date(),4) & Mid(Date(),6,2) ' 현재 월

int_Month_Next = 1 ' 다음 월 증가범위

str_Result = "" ' 결과값 임시 저장


Dim arrResult(100) ' 결과값 배열

Dim n ' 배열 넘버링

n=0

'&&&&&&&&&&&&&&&&&&& 변수 초기화 - 종료

%>

<%

'&&&&&&&&&&&&&&&&&&& 연월호 값 동적으로 저장하기 - 시작

If IsArray(arr_Get_Data) Then ' 데이터 존재여부 확인

For int_Month_Init=201307 To int_Month_Now Step int_Month_Next ' 최초 월부터 현재 월까지 루프

str_Result = CStr(int_Month_Init) ' 현재월 데이터 저장


If Right(int_Month_Init, 2) = 13 Then ' 13월 이라면, 연도+1 하여 내년의 1월로 변경

str_Result = Left(int_Month_Init, 4)+1&"01"

int_Month_Init = Int(str_Result)

End If


arrResult(n) = str_Result ' 실질적인 데이터 저장을 위한 배열

n = n + 1 ' 배열 플래그 증가

Next

End If

'&&&&&&&&&&&&&&&&&&& 연월호 값 동적으로 저장하기 - 종료

%>



<div align="right">

<select style="width: 120px;" name="issu" onchange="javascript:open_popup(this.value);">

<option name="issu" value="0" selected="selected">지난호 보기</option>


<%

'&&&&&&&&&&&&&&&&&&& 연월호 값 option의 value에 넣기 - 시작

If IsArray(arrResult) Then ' 배열 데이터 존재여부 확인

For n=0 To UBound(arrResult) Step 1 ' 배열 범위만큼 루프

If IsEmpty(arrResult(n)) Then ' 배열 데이터 값이 없으면 종료

Exit For

Else

%>

<option name="issu" value="<%=arrResult(n)%>">

<%=Left(arrResult(n),4)%>년 <%=Right(arrResult(n),2)%>월호

</option>


<%

End if

Next

End If

'&&&&&&&&&&&&&&&&&&& 연월호 값 option의 value에 넣기 - 종료

%>


</select>

</div>

<%

'=========================================================================== 동적으로 연월호 값 가져오기 - 종료

%>



'◆ 무한한 가능성 > & ASP' 카테고리의 다른 글

ASP.NET MVC5 example tutorial  (0) 2015.06.02