PHP+ajax real-time input automatic search matching method

墨辰丷
Release: 2023-03-30 10:58:02
Original
2543 people have browsed it

This article mainly introduces the method of automatic search and matching of php ajax real-time input. Interested friends can refer to it. I hope it will be helpful to everyone.

dropbox_index.php

   主搜索引擎下拉框自动显示数据 

Copy after login

dropbox.js ajax

var xmlHttp function showHint(str) { if (str.length==0) { document.getElementById("txtHint").innerHTML="" return } xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return } var url="responsepage.php" url=url+"?q="+str url=url+"&sid="+Math.random() xmlHttp.onreadystatechange=stateChanged xmlHttp.open("GET",url,true) xmlHttp.send(null) } //设置回调函数 function stateChanged() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("txtHint").innerHTML=xmlHttp.responseText } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; }
Copy after login

dropbox.css

.txt{ height:22px; border:1px solid #cdcdcd; width:220px;border-right:none;}
.btn{ background-color:#FFF; border:1px solid #CDCDCD;height :26px; width:70px;}

responsepage.php

"; //echo "lastname:" . $row['LastName'] . "
"; //echo "age:" . $row['Age'] . "
"; } //echo $row['FirstName'] . "
"; } mysql_close($con); } ?>
Copy after login

Database:

Summary: The above is the entire content of this article, I hope it will be helpful to everyone's study.

Related recommendations:

The function of ZipArchive function in php

php How to serialize and serialize data Deserialization

phpHow to get the operating system type

The above is the detailed content of PHP+ajax real-time input automatic search matching method. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!