Page 1 of 1

Autocomplete

Posted: Fri Dec 09, 2016 1:15 pm
by tqmd1
Sir I have these codes

Code: Select all

<html>
    <head>
    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript" src="js/jquery-ui.js"></script>
    <link rel="stylesheet" href="css/jquery-ui.css">
    <script type="text/javascript">
    $(function() 
      {
          $( "#coding_language" ).autocomplete({
              source: 'autocomplete.php'
          });
      });
</script>
    </head>
    <body>
    <div id="wrapper">
    <div class="ui-widget">
    <p>Code <input type="text" id="PT"></p>
    <p>Party <input type="text" size="40" id="coding_language"></p>
    </div>
    </div>
    </body>
</html>
and autocomplete.php has these codes

Code: Select all

<?php
include_once("includes/connectsql.php");
$searchTerm = $_GET['term'];
$query = "SELECT * FROM master WHERE desc1 LIKE '".$searchTerm."%'";
$select = sqlsrv_query($con,$query) or die ("Error". sqlsrv_errors($con)) ;  
while ($row=sqlsrv_fetch_array($select)) 
{
    $data[] =$row['code'].' - '. $row['desc1'];
}
//return json data
echo json_encode($data);
?>
The codes replies this data

Image

When I Enter the name of any CONTACT then his name + his code appear in same textbox
But I want the code to appear in CODE text box,
I want to get code and name in separate boxes.

In screenshot, I pressed ALI.

Please help

Re: Autocomplete

Posted: Fri Dec 09, 2016 3:19 pm
by Christopher
See the documentation about the response() event handler. You will need to split the values and update the other text box yourself.