ASP 파라메터 컨트롤 함수

ASP 2012. 1. 9. 17:25 Posted by Dayis

url 정보의 파라메터 및 쿼리스트링 자유롭게 조정하는 함수개발 중에 만들어진 함수 입니다.
각 페이지마다 링크걸기가 귀찮고, 소스가 지져분해져서 만들게 되었네요.

해당 페이지의 파라메터 정보 즉, 쿼리스트링을 불러오는 함수입니다.
불러온 파라메터의 부분 부분 삭제 및 수정이 가능하여 사용이 편리하다는 장점이 있습니다.

이동할 페이지가 정해져 있고 파라메터로 페이지 컨트롤할 경우 ?chn=blog
? 를 붙여 주시면 됩니다. ^-^ 대부분 아시겠지만 ... 1%를 위해서!!

* 자주 사용하는 함수명은 짧은게 좋아요 !!
* 페이지 이동을 파라메타로 개발하시는 분에게 권하는 함수입니다.
index.asp -> list.asp (x)
index.asp -> index.asp?mode=list (o)

-------------------------------------------------------------------------------------------

 

[2008.03.26] 값 없는 파라메터 필터링
chn=blog&mode=syaku&type=&page=2
위와 같은 파라메터인 경우 &type= 부분은 자동 삭제됩니다.
chn=blog&mode=syaku&page=2

[2008.05.29] 
값이 없는 파라메터 자동 삭제 버그 수정 (위 방법 올바르게 안되는 부분 수정)

이전 페이지 값 가져 오기
예) 로그인 하지않은 상태에서 특정페이지에 접근하게 되면, 이전 페이지의 파라메터 정보를 읽어 
로그인 페이지로 전송하면 됩니다.

[2008.06.30]
쿼리스트링 끝 부분에 & 가 붙는 경우 삭제함.

# 원본 소스
<%@LANGUAGE="VBSCRIPT"%>
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
<% Option Explicit %>

<%
Public Function Para(Ar)
        Dim Reg
        Dim query,reg_query,key,str
        query = Request.ServerVariables("QUERY_STRING")
        
        Set Reg = New RegExp
        Reg.Global = True
        
        '// 2008.03.26 파라메터 필터링 1차 수정
        '//Reg.Pattern = "([A-Za-z0-9_-]+)=(&|$)"
        '//query = Reg.Replace(query,"&")
        
        '// 2008.05.29 파라메터 필터링 2차 수정
        Reg.Pattern = "(&|)([A-Za-z0-9\%\_\-]+)=(&|$)"
        query = Reg.Replace(query,"&")
        
        If IsArray(Ar) Then
                For Each key In Ar
                        str = key(0) & "=" & key(1)
                        Reg.Pattern = "(" & key(0) & ")=([^&]+)?"
                        If key(1) = "" Then
                               query = Reg.Replace(query,"")
                        Else
                               query = Reg.Replace(query,str)
                        End If
                Next 
        
        '// 2008.05.29 이전 페이지 돌아가기
        Else
                If Ar = "HTTP_REFERER" Then
                        query = Request.ServerVariables("HTTP_REFERER")
                        
                        Reg.Pattern = "^(http|ftp|mail|https):\/\/(.*)\/(.*)\?"
                        query = Reg.Replace(query,"")
                End If
        End If
        
        '// 200.06.30 끝부분에 & 붙으면 제거함.
        Reg.Pattern = "&$"
        query = Reg.Replace(query,"")
        Set Reg = Nothing
        
        Para = query
End Function
%>

 

#예제 소스
<%@LANGUAGE="VBSCRIPT"%>
<% Option Explicit %>
<%
'// 현 파라메터 불러오기
response.write Para("") & "<br>"
'// 결과 : chn=blog&mode=syaku&page=2

'// 현 파라메터 일부분 수정하기
response.write Para(Array(Array("mode","kor_no"))) & "<br>"
'// 결과 : chn=blog&mode=kor_no&page=2

'// 현 파라메터 일부분 삭제하기
response.write Para(Array(Array("&page",""))) & "<br>"
'// 결과 : chn=blog&mode=syaku

'// 현 파라메터 여러부분 수정및 삭제하기
response.write Para(Array(Array("chn","good"),Array("mode","end"),Array("&page",""))) & "<br>"
'// 결과 : chn=good&mode=end

'// 이전페이지 파라메터 읽어오기
response.write Para("HTTP_REFERER") & "<br>"
%>

'ASP' 카테고리의 다른 글

ASP 프레임워크(Framework)  (0) 2014.12.05
ASP 입력값 Replace (따옴표, 작은따옴표..)  (0) 2013.05.01
jquery 파일 업로드  (0) 2010.12.10
구글맵  (0) 2010.12.09
구글맵 API Key 생성 URL  (0) 2010.12.01

jquery 파일 업로드

ASP 2010. 12. 10. 18:43 Posted by Dayis

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>비동기 파일업로드 (www.hanji.pe.kr)</title>
<link href="/css/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript" src="/js/jquery.form.js"></script>
<script type="text/javascript">
<!--
//ajax오류시 메세지 나오게함
$(document).ajaxError(function(info,xhr){
 if(xhr.status==500)
 alert("데이터 저장시 오류가 발생하였습니다.");
});

//파일전송 후 콜백 함수
function FileuploadCallback(data,state){
 if (data=="error"){
  alert("파일전송중 오류가 발생하였습니다.\n다시한번 시도해주세요.");
  //location.reload();
  return false;
 }
 alert("파일전송이 완료되었습니다.");
}

//비동기 파일 전송
$(function(){
 var frm=$('#frmFile');
 frm.ajaxForm(FileuploadCallback);
 frm.submit(function(){return false; });
});

// 파일업로드 이벤트
function FileUpload(){
 if(!$("#Filename").val()){
 alert("파일을 선택하세요.");
 $("#Filename").focus();
 return;
 }

 //파일전송
 var frm;
 frm = $('#frmFile');
 frm.attr("action","./ajax_fileupload.asp");
 frm.submit();
}
-->
</script>
</head>
<body>
<div style="width:350px">
<form id="frmFile" name="frmFile" method="post" enctype="multipart/form-data">
<table cellpadding="0" cellspacing="1"  id="TableSt01"  class="row" style="width:350px">
<tr><th><h2>파일을 선택하세요.</h2></th></tr>
<tr><td>
 <input type="file" size="30" name="Filename" id="Filename" />
 <input type="button" class="btn menu" value="확인" onclick="FileUpload();" />
</td></tr>
</table>
</form>
</body>
</html>

'ASP' 카테고리의 다른 글

ASP 입력값 Replace (따옴표, 작은따옴표..)  (0) 2013.05.01
ASP 파라메터 컨트롤 함수  (0) 2012.01.09
구글맵  (0) 2010.12.09
구글맵 API Key 생성 URL  (0) 2010.12.01
ASP 배열을 자바스크립트 배열로 변경  (0) 2010.12.01

구글맵

ASP 2010. 12. 9. 11:43 Posted by Dayis

예상했던 것보다 훨씬 똑똑하다.
거기다 무료로 이용할 수 있으니 구글제품을 안 쓸래야 안 쓸 수가 없다.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
session.CodePage=65001
response.CharSet="utf-8"
%>
<!-- 구글맵 관련 스크립트 -->
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script src="http://maps.google.com/maps?file=api&v=2.x&key=사이트키값&language=ja" type="text/javascript"></script>
<script type="text/javascript" >
var xmlHttp;
var map = null;
var geocoder = null;
var marker = null;

//지도 초기화
function gMapInit() {
 if (GBrowserIsCompatible())
 {
  var point = new GLatLng('37.5091548', '127.1173515');
  map = new GMap2(document.getElementById("gMapCanvas"));
  map.addControl(new GSmallMapControl());
  map.addControl(new GMapTypeControl());
  map.addControl(new GScaleControl()); // add
  map.setCenter(point, 15);

  //초기화 좌표 위치에 마커설정
  marker = new GMarker(point);
  map.addOverlay(marker);
  document.getElementById('gMapLatitude').value = point.y;
  document.getElementById('gMapLongitude').value =point.x; 

  //지도상의 클릭 좌표에 마커설정
  //GEvent.addListener(map, "click", getAddGeocoder);
  geocoder = new GClientGeocoder();
 }
}

function getAddGeocoder(overlay, latlng) {
      if (latlng != null) {
        address = latlng;
        geocoder.getLocations(latlng, showAddress);
     }    
}

function searchGeocoderByAddMap(){
 var objForm = document.objForm;
 var addrVal = objForm.addrProvince.value + ' ' +  objForm.addrDistrict.value + ' ' + objForm.addrTown.value + ' ' +  objForm.addrHouseno.value ;

 /*
 if(objForm.addrProvince.value == ""){  
  alert("addrProvince 넣어 주세요.");
  return;
 }
 if(objForm.addrDistrict.value == ""){  
  alert("addrDistrict 넣어 주세요.");
  return;
 }

 if(objForm.addrTown.value == ""){  
  alert("addrTown 넣어 주세요.");
  return;
 }
 if(objForm.addrHouseno.value == ""){  
  alert("addrHouseno 넣어 주세요.");
  return;
 }
 */

 if (geocoder) {
  geocoder.getLatLng(addrVal, function(point) {
   if (!point) {
    alert(addrVal + " not found");
   } else {
    map.clearOverlays();
    map.setCenter(point, 15);
     marker = new GMarker(point);
     map.addOverlay(marker);
     document.getElementById('gMapLatitude').value = point.y;
     document.getElementById('gMapLongitude').value =point.x; 
   }
  }
  );
 }
}

function showAddress(response) {
    map.clearOverlays();
    document.getElementById('addrProvince').value = "";
    document.getElementById('addrDistrict').value = "";
    document.getElementById('addrTown').value = "";
   
    if (!response || response.Status.code != 200) {
      alert("Status Code:" + response.Status.code);
    } else {
      place = response.Placemark[0];
      point = new GLatLng(place.Point.coordinates[1],
                          place.Point.coordinates[0]);
      marker = new GMarker(point);
      map.addOverlay(marker);
  document.getElementById('gMapLatitude').value = place.Point.coordinates[1];
  document.getElementById('gMapLongitude').value =place.Point.coordinates[0];
  var a = place.address.split(" ");
  var addrBasic ="";
  
  for(var i=1;i<a.length;i++){   
   if(i==1){
    document.getElementById('addrProvince').value  =  a[i];
    addrBasic += a[i] + " ";
   }
   else if(i==2){
    document.getElementById('addrDistrict').value  =  a[i];
    addrBasic += a[i] + " ";
   }
   else if(i==3){
    document.getElementById('addrTown').value  =  a[i];
    addrBasic += a[i] + " ";
   }
   else if(i==4 && a.length != 5){
    document.getElementById('addrHouseno').value  =  a[i];
    addrBasic += a[i];
   }    
   else if(i ==(a.length-1)){
    document.getElementById('addrHouseno').value  =  a[i];    
   }
   else{}
  }
    }
}
</script>
<script language='javascript' for="window" event="onload">
gMapInit();  //로드시 맵초기화
//searchGeocoderByAddMap();  //로드시 기본좌표로 검색
</script>
<!-- /구글맵 관련 스크립트 -->
<form id="objForm" name="objForm" method="post">
<div><span>&nbsp;* gCode 확인 * </span></div>
<div>
1. 지도를 클릭한다.<br>
2. 각 필드에 데이터를 넣고 '검색'을 클릭한다.<br>
 <table id="table" width="450" border="1" cellspacing="0" cellpadding="0"  bordercolor="#dee2e7" > 
  <tr>
   <td>시 / 도</td>
   <td><input name="addrProvince" id="addrProvince" style="width:300px;" type="text" size="11" maxlength="200" maxbyte_utf8="15" /></td>
  </tr>
  <tr>
   <td>구 / 군</td>
   <td><input name="addrDistrict" id="addrDistrict" style="width:300px;" type="text" size="11" maxlength="200" maxbyte_utf8="15" /></td>
  </tr>
  <tr>
   <td>동(읍/면/리)</td>
   <td><input name="addrTown" id="addrTown" style="width:300px;" type="text" size="11" maxlength="200" maxbyte_utf8="15" /></td>
  </tr>
  <tr>
   <td>기타주소</td>
   <td>
    <input name="addrHouseno" id="addrHouseno" style="width:300px;" type="text" size="11" maxlength="200" maxbyte_utf8="15"  />
    <a href="javascript:searchGeocoderByAddMap();">검색</a>
   </td>
  </tr>
  <tr>
   <td colspan='2'>&nbsp;</td>
  </tr>
  <tr>
   <td>Longitude</td>
   <td><input name="gMapLongitude" id="gMapLongitude" style="width:300px;" type="text" size="11" maxlength="200" maxbyte_utf8="15"  value="127.1173515"/></td>
  </tr>
  <tr>
   <td>Latitude</td>
   <td><input name="gMapLatitude" id="gMapLatitude" style="width:300px;" type="text" size="11" maxlength="200" maxbyte_utf8="15" value="37.5091548" /></td>
  </tr>     
 </table>
</div>
<div width="100%">
 <table id="" width="100%" border="0" cellspacing="0" cellpadding="0" background bgcolor="">
  <tr><td width="50%">
   <div id="gMapCanvas" style="width: 500px; height: 400px"></div>
  </td></tr>
 </table>
</div>
</form>  

'ASP' 카테고리의 다른 글

ASP 파라메터 컨트롤 함수  (0) 2012.01.09
jquery 파일 업로드  (0) 2010.12.10
구글맵 API Key 생성 URL  (0) 2010.12.01
ASP 배열을 자바스크립트 배열로 변경  (0) 2010.12.01
전각/반각 구분하여 문자열 계산  (0) 2010.10.05

구글맵 API Key 생성 URL

ASP 2010. 12. 1. 16:53 Posted by Dayis

'ASP' 카테고리의 다른 글

ASP 파라메터 컨트롤 함수  (0) 2012.01.09
jquery 파일 업로드  (0) 2010.12.10
구글맵  (0) 2010.12.09
ASP 배열을 자바스크립트 배열로 변경  (0) 2010.12.01
전각/반각 구분하여 문자열 계산  (0) 2010.10.05

ASP 배열을 자바스크립트 배열로 변경

ASP 2010. 12. 1. 14:04 Posted by Dayis

<SCRIPT LANGUAGE="JavaScript">
<!--
 var tmpNum = 0;
 var ArrPostScript = new Array();

 <% for i=0 to MaxNum %>
  ArrPostScript[tmpNum] = "<%=arrPost(2,i)%>";
  tmpNum++;
 <% Next %>
//-->
</SCRIPT>

'ASP' 카테고리의 다른 글

ASP 파라메터 컨트롤 함수  (0) 2012.01.09
jquery 파일 업로드  (0) 2010.12.10
구글맵  (0) 2010.12.09
구글맵 API Key 생성 URL  (0) 2010.12.01
전각/반각 구분하여 문자열 계산  (0) 2010.10.05

전각/반각 구분하여 문자열 계산

ASP 2010. 10. 5. 16:31 Posted by Dayis
Function chrbyte(str,strlen)
 Dim returnStr, charat, cutchk, wLen, j
 cutchk = 0

 for j=1 to len(str)
  charat=mid(str, j, 1)
  if asc(charat)>0 And asc(charat)<255 Then
   If asc(charat) = 1 Then
    wLen=wLen+2 
   Else
    wLen=wLen+1 
   End If
  Else
   wLen=wLen+2
  end If
  
  returnStr = returnStr & charat

  If wLen >strlen Then
   cutchk = 1
   Exit for
  End if
 Next
 
 If cutchk = 1 then
  chrbyte = returnStr & ".."
 Else
  chrbyte = returnStr
 End if
end Function

'ASP' 카테고리의 다른 글

ASP 파라메터 컨트롤 함수  (0) 2012.01.09
jquery 파일 업로드  (0) 2010.12.10
구글맵  (0) 2010.12.09
구글맵 API Key 생성 URL  (0) 2010.12.01
ASP 배열을 자바스크립트 배열로 변경  (0) 2010.12.01