lundi 20 février 2017

jQuery automcplete: How to suggest 2 values, but select only one of them?

The idea is that a user can input a surname OR a corresponding id and every automplete suggestion field will look like "Surname - ID" See this picture, but when a user chooses any item from the list, only one value (Surname) will be chosen.

I successfully implemented the part with 2 suggested values, but when I choose one item, both Surname and ID are being chosen. What am I change to select only one value into the textbox (Surname), but leave 2 suggested values? Here is the snippet of code:

$select =mysqli_query($conn, "SELECT * FROM seamstress WHERE surname LIKE '%".$searchTerm."%' OR seamstress_id LIKE '%".$searchTerm."%'");

while ($row=mysqli_fetch_array($select)) {
    $data[] = $row['surname']. ' '.$row['seamstress_id'];
}
echo json_encode($data);




Aucun commentaire:

Enregistrer un commentaire