如何将单个 jquery 自动完成用于多个表单下拉列表?
这是我的视图页面(标题):
$("#full_name").autocomplete({
source: "<?php echo site_url('autocomplete/get_names');?>"
});
$("#department").autocomplete({
source: "<?php echo site_url('autocomplete/get_dept');?>"
});
*** and other like these for subjects, zip and country.
控制器页面:
public function get_names(){
$this->load->model('autocomplete_model');
if (isset($_GET['term'])){
$q = strtolower($_GET['term']);
$this->autocomplete_model->get_fullnames($q);
}
}
*** and other functions...
型号页面:
function get_fullnames($q)
{
$match = $q;
$this->db->select('full_name');
$this->db->like('full_name', $match,'after');
$query = $this->db->get('employee_list');
if($query->num_rows > 0){
foreach ($query->result_array() as $row){
$row_set[] = htmlentities(stripslashes($row['full_name']));
}
echo json_encode($row_set);
}
}
如何实现可用于多个条件的单个搜索词?
提前谢谢你们..