3초기억력

asp 자동검색어 - ajax 본문

플밍_ASP

asp 자동검색어 - ajax

잠수콩 2015. 3. 5. 16:28
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.



제목 :  asp 자동검색어 - ajax


소스 :

 

index.asp

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

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001" %>
<%
 Session.CodePage = "65001"
 Response.CharSet = "UTF-8"

 'ON ERROR RESUME Next

 Response.Buffer = true
 Response.Expires = -1
%>
<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="Generator" content="EditPlus®">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <title>Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>

 </head>
 <body>

<p>search text</p>

<input type="text" name="str" id="str" value="" style="width:300px;">
<div id="result" style=" position: absolute;display:none;border:1px silver solid; width:300px; height:200px; overflow:auto;"></div>

<script>
 $(function(){
        $("#str").keyup(function(){

   $('#result').show();

            var str = $(this).val();

            if(str == ""){
                $("#result").html("");
            }

            if(str.length >= 1){
                $.post("search_ajax.asp", {str:str}, function(data){
                    if(data != ""){
                        $("#result").html(data);
                    }
                });
            }
        });
    });

</script>

</body>
</html>

 

 

 

 

search_ajax.asp

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

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001" %>
<%
 Session.CodePage = "65001"
 Response.CharSet = "UTF-8"

 'ON ERROR RESUME Next

 Response.Buffer = true
 Response.Expires = -1
%>
<!--#include virtual="/_include/dbconn.asp"-->
<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
 <body>
<%
 strWord = Replace(Trim(request("str")), " ", "")

 If strWord <> "" Then
  sql = "select uid, title from table_goods where replace(rtrim(title), '-', '') like '%"& strWord &"%'"
  'Response.write sql
  Set rs = db.execute(sql)

  If Not(rs.eof Or rs.bof) Then
   Do Until rs.eof
    Response.write "<a href=""http://demo3.mallshopping.co.kr/goods/content.asp?guid="& rs("uid") &""" target=""_blank"">" & rs("title") & "</a><br>"

    rs.movenext
   Loop
  End If
  rs.close
  Set rs = Nothing
 End If
%>
 </body>
</html>


 


내용 :



예제 소스 파일 :


 출처 :  나혼자


Comments