[eluser]Niebieszki[/eluser]
Hello all
I question about how to put other data in other input fields?
my html file
Code:
[removed]
$(function() {
$( "#company_name" ).autocomplete({
source: function(req, add){
$.ajax({
url: base_url + 'shop/bill/search',
dataType: 'json',
type: 'POST',
data: req,
success: function(data){
if(data.response =='true'){
add(data.message);
}
}
});
},
minLength: 1,
select: function(event, ui){
$(this).end().val(ui.item.value);
}
});
});
[removed]
<div class="ui-widget">
<input type="text" name="company_name" id="company_name" />
<input type="text" name="full_company_name" id="full_company_name" />
<input type="text" name="client_id" id="client_id" />
</div>
my method search:
Code:
public function search(){
$search = $this->input->post('term');
$data['response'] = 'false';
$this->db->select('*');
$this->db->from('client');
$this->db->like('client_company_name', $search);
$locations = $this->db->get()->result();
if(count($locations) > 0){
$data['message'] = array();
foreach($locations as $location){
$data['message'][] = array( 'label' => $location->client_id . ', ' . $location->client_company_name . ' ' . $location->client_full_company_name,
'item' => $location->client_company_name,
'value' => $location->client_company_name );
}
$data['response'] = 'true';
}
echo json_encode($data);
}
How tu put client_id into client_id input fields just then when I chose sth. form company_name input fields??
Any ideas?