Click here to Skip to main content
15,893,161 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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:

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);
        }
Posted
Comments
ridoy 23-Jul-13 7:14am    
really?searched from google! make same topics twice.do your previous question solves your problem?! http://www.codeproject.com/Answers/624796/Autocomplete-using-AJAX-call

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900