get a value from autocomplete

get a value from autocomplete

Hi,

I am using the following jquery and PHP to populate an autocomplete. I will add a btnShowDetails and I woudl like to let the btnShowDetails read the value of the autocomplete (which is the company_guid? How can I do this please.

jquey for autocomplete:
  1. $("input#txtCompanyName").autocomplete
  2.     (
  3.         {
  4.             source : function (request, callback)
  5.             {
  6.                 var data = { term : request.term };
  7.                 $.ajax
  8.                 (
  9.                     {
  10.                         url : "../autocomplete_company.php",
  11.                         data : data,
  12.                         search  : function(){$(this).addClass('working');},
  13.                         open    : function(){$(this).removeClass('working');},
  14.                         complete : function (xhr, result)
  15.                         {
  16.                             if (result !== "success") return;
  17.                             var response = xhr.responseText;
  18.                             var autocomplete_result = [];
  19.                             $(response).filter ("li").each (function ()
  20.                             { autocomplete_result.push ($(this).text ());
  21.                         }
  22.                     );
  23.                     callback (autocomplete_result);
  24.                 }
  25.             }
  26.             );
  27.         }
  28.     }); 

and it's reading from this autocomplete_company.php:
  1. <?php
  2.     include('includes/php_header.php');
  3.     include($_SESSION["absolute_path"] . '/includes/connect2db.php');

  4.     $autocomplete_term = utf8_decode($_REQUEST["term"]);
  5.     
  6.     $mysql_command = "CALL sp_autocomplete_company(:param_company)";
  7.     $mysql_query = $mysql_connection->prepare($mysql_command);
  8.     $mysql_query->bindParam(':param_company', $autocomplete_term, PDO::PARAM_STR);
  9.     $mysql_query->execute();

  10.     while($mysql_row = $mysql_query->fetch())
  11.     {
  12.         echo ("<li>" . utf8_encode($mysql_row['company_name']) . "</li>");
  13.     }
  14. ?>

and here I want to read the autocomplete value:

  1. $('#btnShowDetails').click(function(){
  2.     $.ajax({
  3.         url : "get_company_details.php",
  4.         data : 'id=HERE I WANT TO READ THE VALUE OF THE AUTOCOMPLETE',
  5.         type : "post",
  6.         success : function(data)
  7.         {
  8.             here I am displaying the result
  9.         }
  10.     });
  11. });