[send.asp]
<input type="text" id="text1" name="text" value="abc">
<input type="text" id="text2" name="text" value="def">
<input type="text" id="text3" name="text" value="ghi">
...
[receive.asp]
수신페이지에서
text = trim(request("text"))
arrText = split(text, ",")
for i=0 to ubound(arrText) step 1
response.write "i : " & arrText(i) & "<br>"
next
...
위와 같이 사용하면 편리하나
입력 값이 "," 가 들어간 경우 처리가 힘든 상황이 된다.
이럴경우
[receive.asp]
dim arrTexts()
for i=1 to request("arrText").count '//*,**
Redim Preserve arrTexts(i-1) '//Redim은 배열 재정의하나 앞의 값들이 초기화됨, 따라서 옵션 Preserve 추가
arrTexts(i-1) = request("arrText")(i)
next
위와같이 사용
* count : 컬렉션이나 Dictionary 개체의 항목 수를 반환.
** ubound : 지정한 배열 차원에 사용할 수 있는 가장 큰 첨자를 반환.
*** Redim 프로시저 수준에서 동적 배열 변수를 선언하고 저장 공간을 할당하거나 다시 할당.
**** 마지막 차원의 크기를 바꿀 경우 기존 배열 안에 있는 데이터를 보존.
출처 : kimmogoon
댓글 없음:
댓글 쓰기