I've been working on this for a couple of hours and it should work but i'm missing something!
basically, i'm using jquery autocomplete with json source, with 2 values id and description. Description should show up in suggestions and if item is selected and ID passed to a hidden field ( the field is not hidden currently for testing purposes)
here's my code:
$(function() {
  $("#CurrentProv").autocomplete({
   source: "inc/provider_term.php",
   minLength: 3,
    formatItem: function(data, i, n, value) {   
        return  value.split("|")[1];
          } 
    });
      $("#CurrentProv").result(function(event, data, formatted) {
      if (data)
            $("input#fid").val(data[0]);
      });
});
//PHP valid json output
$term = $_GET['term'];
$sql = "SELECT * FROM db.table WHERE PName LIKE '%$term%'";
$res = mysql_query($sql, $conn) or die(mysql_error());
while ($row = mysql_fetch_array($res)) {
$searchArray['value'] = $row['PID'].'|'.$row['PName'];
$search[] = $searchArray;
}
echo json_encode($search);
I've searched and done various variations and still doesn't work!!! My brain is shutting down!!!!!!!!