본문 바로가기

classic asp

[classic asp] jquery 자동완성

JSON_2.0.4.asp
다운로드
autocomplete.css
다운로드
search.asp
다운로드

 

 

<!doctype html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta charset="euc-kr">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Autocomplete - Default functionality</title>
<link rel="stylesheet" href="autocomplete.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script type="text/javascript">
$.fn.TextClick = (function(n) {
   $( "#tags"+n ).autocomplete({
      minLength: 1,
      source: function( request, response ) {    
         $.ajax({
            url: "search.asp",
            dataType: "json",
            data: { "q" : request.term },
            success: function( data ) {   
            response( $.map( data, function( item ) {
               return { 
                  label: item.data,
                  value: item.data,
                  reference : item.reference
               }
            }));
            }
         });
      },
      focus: function( event, ui )
      {
         $('#tags'+n).val( ui.item.label );
         return false;
      },
      delay: 100, //autocomplete 딜레이 시간(ms)
	   //disabled: true, //자동완성 기능 끄기
      select: function( event, ui )
      {
         $('#tags'+n).val( ui.item.label ); 
         document.getElementById("dtVal").value = ui.item.reference;
         return false;
      },
   });
});

function javaCall(val)
{
   alert(val);
}
</script>
</head>

<body>

<input id="tags1" name="search" type="text" class="input_text" value='' onclick="$(this).TextClick(1);"/>
<input id="dtVal" name="dtVal" type="text" class="input_text" value=''/>
<br>
<input id="tags2" name="search" type="text" class="input_text" value='' onclick="$(this).TextClick(2);" autocomplete="off">
<input id="PaperName" name="PaperName" type="text" class="input_text" value='1' />

</body>
</html>