关键字查询,根据关键字下面对话框实时显示相应的内容例题
效果如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script src="jquery-1.11.2.min.js"></script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> </head> <body> <div style="width:200px; height:35px; border:2px solid #60f"> <input style="width:196px; height:31px;" type="text" id="name" /> </div> <div id="list" style="width:200px; height:500px; border:2px solid #60f "></div> <script type="text/javascript"> $("#name").keyup(function(){ var n=$(this).val(); if(n!="") { $.ajax({ url:"listchuli.php", data:{n:n}, type:"POST", dataType:"TEXT", success: function(data){ var sz=data.split("|"); var str=""; for(var i=0;i<sz.length;i++){ str=str+"<div class='1'>"+sz[i]+"</div>"; } $("#list").html(str); } }); } else{ $("#list").html(""); } }); </script> </body> </html>
2.处理页面
<?php $name = $_POST["n"]; include("./lei/AAA.class.php"); $db = new AAA(); $sql = "select name from info where name like '%{$name}%' "; echo $db->StrQuery($sql);
posted on 2016-11-11 15:37 向前看!明天会更好! 阅读(173) 评论(0) 编辑 收藏 举报