html程序:
复制内容到剪贴板
代码:
<!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" />
<title>无标题文档</title>
<style type="text/css">
.mouseOut {
background: #708090;
color: #FFFAFA;
}
.mouseOver {
background: #FFFAFA;
color: #000000;
}
</style>
<script language="javascript">
var xmlHttp;
function createXMLHttpRequest(){
if(window.ActiveXObject){
xmlHttp= new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest){
xmlHttp= new XMLHttpRequest();
}else{
alert("false");
}
}
function startrequest(){
var ttv=document.getElementById("inkey").value;
createXMLHttpRequest();
xmlHttp.onreadystatechange=test;
var url="ptt.php?ck="+escape(ttv);
xmlHttp.open("GET",url,true);
//xmlHttp.open("GET","ptt.xml",true);
xmlHttp.send(null);
}
function test(){
if(xmlHttp.readyState==4){
if(xmlHttp.status==200){
cleanbefore();
testmore();
}
}
}
function cleanbefore(){
var addvv=document.getElementById("add");
var cac=addvv.childNodes.length;
while(cac > 0) {
addvv.removeChild(addvv.childNodes[0]);
cac=addvv.childNodes.length;
}
}
function testmore(){
var xmldoc=xmlHttp.responseXML;
var nott=xmldoc.getElementsByTagName("ptt");
var nolen=nott.length;//alert(nolen);
for(var i=0;i<nolen;i++){
var vv=nott[i];
var vll=vv.firstChild.nodeValue;
ehh(vll);
}
}
function ehh(ttnn){
var dvv=document.createElement("div");
dvv.onmouseout = function() {this.className='mouseOver';};
dvv.onmouseover = function() {this.className='mouseOut';};
dvv.onclick = function() { onc(this); } ;
var inconn=ttnn;
var pp = document.createTextNode(inconn);
dvv.appendChild(pp);
document.getElementById("add").appendChild(dvv);
}
function onc(nono){
var nova=nono.firstChild.nodeValue;
document.getElementById("inkey").value=nova;
cleanbefore();
}
</script>
</head>
<body>
<input type="text" style="width:150px; text-align:left" id="inkey" onkeyup="startrequest()" />
<div id="add" style="width:150px">
</div>
</body>
</html>php程序:
复制内容到剪贴板
代码:
<?php
$check=$_GET['ck'];
if($check!=""){
$mycon_c=mysql_connect("localhost","root","cnk8");
$mysdb=mysql_select_db("test");
$str="select nn from ajax where nn like '$check%'";
$fop=fopen("nnd.txt","a+");
$w="---------".date("Y-m-d H:i:s")."---\n$str\n************\n";
fwrite($fop,$w);
$que=mysql_query($str);
header("Content-type: 'text/xml'");
echo "<?xml version='1.0' encoding='UTF-8'?><ptts>";
while($row=mysql_fetch_row($que)){
echo "<ptt>{$row[0]}</ptt>";
}
echo "</ptts>";
}
?>