I have been creating a webpage that has a searchbox with a real-time AJAX autosuggest feature, however have come up against a slight problem...
I've managed to get the search function to use a MySQL database to find names similar to the text entered so far... and return the results as a list like this...
Code: Select all
$querySQL = "SELECT DISTINCT Surname FROM `ClientDetails` WHERE Surname LIKE '$nameSearch%'";
$query = mysql_query($querySQL);
while ($row = mysql_fetch_array($query)) {
$LastName .= "<li><a href=\"#\" onClick=\"fillName(this)\">".$row['Surname']."</a></li>";
}
Code: Select all
function fillName(obj) {
document.forms["studentCheck"]["LastName"].value = obj.value;
}
Can anybody give me some pointers please?