<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> <!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> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <script type="text/javascript"> <!-- var xmlhttp; try{ xmlhttp= new ActiveXObject('Msxml2.XMLHTTP'); }catch(e){ try{ xmlhttp= new ActiveXObject('Microsoft.XMLHTTP'); }catch(e){ try{ xmlhttp= new XMLHttpRequest(); }catch(e){} } } function getName() { var myname; myname = document.getElementById("myname").value; xmlhttp.open("get","xmlhttp.asp?myname="+myname); xmlhttp.onreadystatechange = function(){ if(xmlhttp.readyState==4){ if(xmlhttp.responseText==true){ document.getElementById("myname").value=""; document.getElementById("msg").innerHtml ="已经存在";} else{document.getElementById("msg").innerHtml ="可以使用";} } } xmlhttp.setRequestHeader("If-Modified-Since","0"); xmlhttp.send(null); } //--> </script> <title>实现即时查找数据</title> </head> <body> Name:<input type="text" id="myname" name="myname" onKeyup="javascript:getName();"> <div id=msg></div> < </body> </html>
<% Set conn=Server.CreateObject("ADODB.CONNECTION") conn.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ="&Server.Mappath("test.mdb") set rs = server.CreateObject ("adodb.recordset") id=Request.QueryString("id") sql="select * from news where myname='"&myname&"'" rs.open sql,conn,1,1 if not rs.bof then response.Write true else response.Write false end if %>