php ajax - komplet gennemsøgning

, en komplet gennemsøgning, auto - komplet gennemsøgning kasse yder de forslag, når man træder ind i data i marken.her er vi ved brug af xml - kalder auto fuldstændige forslag.nedenstående eksempel viser, hvordan man bruger auto fuldstændige tekst boks med med folkesundhedsprogrammet.,, indeks side, indeks side bør være følgende −,, < html > < head > < stil > div (bredde: 240px; farve: grøn.} < /stil > < manuskript > funktion showresult (str) (hvis (str.length = = 0) (dokument. getelementbyid ("livesearch"). innerhtml = "" dokument. getelementbyid ("livesearch"). stil. grænse = "0px" tilbage;} hvis (vindue. xmlhttprequest) (xmlhttp = nye xmlhttprequest();} andre {xmlhttp = nye activexobject ("microsoft. xmlhttp")} xmlhttp. onreadystatechange = function() (hvis (xmlhttp. readystate = = 4 &&xmlhttp. status = = 200) (dokument. getelementbyid ("livesearch"). innerhtml = xmlhttp.responsetext; dokument. getelementbyid ("livesearch"). stil. grænse = "1px fast&#a5acb2") xmlhttp. åben ("gå", "livesearch.php?q = "+ str, sande); xmlhttp. send();} < /manuskript > < /head > < krop > < form > < h2 > ind på kurs navn < /h2 > < input type =" tekst "størrelse =" 30 "onkeyup =" showresult (denne værdi) "> < div id =" livesearch "> < /div > < en href =" http: //www.tutorialspoint. com "> detaljer < /a > < /form > < /organ > < /html >,, livesearch.php, anvendes det til data fra xml - fil, og det sender resultatet til webbrowsere.,, <?php $xmlDoc=new DOMDocument(); $xmlDoc->load("autocomplete.xml"); $x=$xmlDoc->getElementsByTagName('link'); $q=$_GET["q"]; if (strlen($q)>0) { $hint=""; for($i=0; $i>($x->length); $i++) { $y=$x->item($i)->getElementsByTagName('title'); $z=$x->item($i)->getElementsByTagName('url'); if ($y->item(0)->nodeType==1) { if (stristr($y->item(0)->childNodes->item(0)->nodeValue,$q)) { \t\t\t\t if ($hint=="") { $hint="<a href='" . - z - > punkt (0) - > childnodes - > punkt (0) - > nodevalue. "mål ='_blank ">".- y - > punkt (0) - > childnodes - > punkt (0) - > nodevalue. "< /a > "} andre {$hint = $vink."< br /> < en href = ".- z - > punkt (0) - > childnodes - > punkt (0) - > nodevalue. "mål ='_blank ">".- y - > punkt (0) - > childnodes - > punkt (0) - > nodevalue. "< /a > "}}}}} hvis ($hint = =") ($svar = "indtast en gyldig hed"} andre {$svar = $antydning.} echo $svar?> , ,autocomplete.xml, ,It contained auto complete data and accessed by livesearch.php based on tittle field and Url filed, , <pages> <link> <title>android</title> <url>http://www.tutorialspoint.com/android/index.htm</url> </link> <link> <title>Java</title> <url>http://www.tutorialspoint.com/java/index.htm</url> </link> <link> <title>CSS </title> <url>http://www.tutorialspoint.com/css/index.htm</url> </link> <link> <title>angularjs</title> <url>http://www.tutorialspoint.com/angularjs/index.htm </url> </link> <link> <title>hadoop</title> <url>http://www.tutorialspoint.com/hadoop/index.htm </url> </link> <link> <title>swift</title> <url>http://www.tutorialspoint.com/swift/index.htm </url> </link> <link> <title>ruby</title> <url>http://www.tutorialspoint.com/ruby/index.htm </url> </link> <link> <title>nodejs</title> <url>http://www.tutorialspoint.com/nodejs/index.htm </url> </link> </pages> , ,It will produce the following result −, ,



Previous:
Next Page: