this is my code have searched through google,
but is prompt an error that select:function(event,ui) does not exists. my code is as follow: i have used:
<script type="text/javascript" src="jqueryui\jquery.autocomplete.js"></script>
and:
$(document).ready(function() {
$('#add_event_customer_name').autocomplete({
source: function (request, response) {
$.ajax({
// url: "bal/getCustomerDetail.php", //Call to Server Side
url:":/bal/getCustomerDetail.php",
data: "{ term: request.term }",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
success: function (result) {
response(result);
}
});
},
open: function (event, ui) {
$(this).autocomplete("widget").css({
"width": 344,
"font-size": 11,
"font-family": "Arial"
});
},
Select:function(event,ui)
{
// when a customer name is selected, populate related fields in respective control
this.createeventform.add_event_customer_phone.value = ui.item.phone;
this.createeventform.add_event_customer_mobile.value = ui.item.mobile;
this.createeventform.add_event_customer_email.value = ui.item.email;
this.createeventform.add_event_customer_fax.value = ui.item.fax;
this.createeventform.add_event_customer_address.value = ui.item.address;
}
});
input tag is:
<input type="text" name="event_customer_name" id="add_event_customer_name" class="validate[required,custom[onlyLetter]] text ui-widget-content ui-corner-all"/>.
data page :
getCustomerDetail.php:
session_start();
include '../config.php';
include_once('../class/events.php');
$eventobj = new event();
$eventobj->getCustomerDetail($_POST['add_event_customer_name']);
class file: events.php:
function getCustomerDetail($custName)
{
$db = new emgrdb();
$customer="SELECT id, name, email, phone, mobile,fax,address FROM customer where name like '$custName%'";
$cust_query=$db->fetch_array($customer,$db);
echo "SELECT id, name, email, phone, mobile,fax,address, FROM customer where name like '$custName%'";
if(!empty($cust_query))
{
$data[]=array(
'value'=>$cust_query['name'],
'email'=>$cust_query['email'],
'phone'=>$cust_query['phone'],
'mobile'=>$cust_query['mobile'],
'fax'=>$cust_query['fax'],
'address'=>$cust_query['address']
);
}
echo json_encode($data);
}