<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>数据查询</title>
<style type="text/css">
td{
text-align:center;
width:150px;
height:60px;
}
th{
width:300px;
height:60px;
}
table{
border:solid 0px #000000;
}
input{
margin-top:60px;
margin-left:50px;
width:200px;
height:40px;
}
button{
border-radius:5px 5px 5px 5px;
border:solid 1px royalblue;
background-color:#ffffff;
width:150px;
height:40px;
}
#cha1{
display:none;
}
</style>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
</script>
</head>
<body>
<p>在以下输入框中输入名字:</p>
第一个名称:
<input type="text" onmousedown="lin();" />
<p>匹配项: <span></span></p>
<script>
function lin(){
$("input").val("");
}
$(document).ready(function(){
$("input").keyup(function(){
txt=$("input").val();
$.get("c.php",{suggest:txt},function(result){
$("span").html(result);
});
});
});
</script>
<style type="text/css">
.wrapper {position: relative;}
#input {position: absolute;top: 0;left: 0;opacity: 0;z-index: -10;}
</style>
<textarea id="input">这是幕后黑手</textarea>
<script type="text/javascript">
function copyText() {
var text = document.getElementById("text").innerText;
var text1 = document.getElementById("text1").innerText;
var text2 = document.getElementById("text2").innerText;
var input = document.getElementById("input");
$("#text").click(function(){
input.value = text;
input.select(); // 选中文本
document.execCommand("copy");
});
$("#text1").click(function(){
input.value = text1;
input.select(); // 选中文本
document.execCommand("copy");
});
$("#text2").click(function(){
input.value = text2;
input.select(); // 选中文本
document.execCommand("copy");
});
//alert("复制成功");
}
</script>
</body>
</html>
---------------------------------------------
c.php
<?php
$ru = $_GET['suggest'];
if($ru){
$host="127.0.0.1";
$usert="";
$passu="";
$npp="";
$conn=mysql_connect($host,$usert,$passu) or die("连接数据库失败");
mysql_select_db($npp);
mysql_query("set names utf8");
$r =$_GET['do'];
$sql=mysql_query("SELECT * FROM sheet1 where E = '$ru'");
$ut = mysql_fetch_array($sql);
echo "<td > ".$ut['E']."</td><td id='text'> <button onclick='copyText()'>".$ut['D']."</button></td><td id='text1'><button onclick='copyText()'>".$ut['G']."</button></td><td id='text2'><button onclick='copyText()'>".$ut['O']."</button></td>";
}else{
echo "无数据";
}
?>