model
Código PHP:
function showProvider(){
$query = $this->db->select('provider_id, provider_name');
$query = $this->db->from('tbl_provider');
$query = $this->db->order_by("provider_name", "desc");
$query = $this->db->get();
return $query->result();
}
Código PHP:
function providerCombox(){
$this->load->model('mod_Provider');
$datos_vista = "[{";
$cont = 0;
$data = $this->mod_Provider->showProvider();
foreach ($data as $row){
if($cont++>0) $datos_vista .=",";
$datos_vista .= "id:\"$row->provider_id\",name:\"$row->provider_name\"";
}
$datos_vista .="}]";
$this->load->view('new_product',$datos_vista);
}
Código:
gracias $( "#provider" ).autocomplete({ source: '<?php echo base_url().'CI_Provider/providerCombox';?>', minLength: 0, select: function( event, ui ) { $( "provider").val(ui.item.name); }, focus: function( event, ui ) { $( "#provider" ).val( ui.item.name ); return false; } }); });