What I have:
<input name="dcity" placeholder="from" id="from" type="text" onkeyup="showHint(this.value)" > <input name="acity" placeholder="to" id="to" type="text" onkeyup="showHint(this.value)" > <p>Suggestions: <span id="txtHint"></span></p> function showHint(str) { if (str.length == 0) { document.getElementById("txtHint").innerHTML = ""; return; } else { var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { document.getElementById("txtHint").innerHTML = xmlhttp.responseText; } }; xmlhttp.open("GET", "gethint.php?q=" + str, true); xmlhttp.send(); } I enter the first letters of the city and gives me a hint
$a[] = "Tbilisi"; $a[] = "Rome"; $q = $_REQUEST["q"]; $hint = ""; if ($q !== "") { $q = strtolower($q); $len=strlen($q); foreach($a as $city) { if (stristr($q, substr($city, 0, $len))) { if ($hint === "") { $hint = $city; } else { $hint .= ", $city"; } } } } echo $hint === "" ? "no suggestion" : $hint; This is what I want and I don’t know how to
I will forgive the help, it is very necessary!

