JQuery Autocomplete example in Codeingniter
Hello here simple example to autocomplete setup in codegniter
sample code to use it.
<input type="text" class="form-control skills" name="name" placeholder="Type Name" />
<style>
.fixedHeight {
font-size:10px;
max-height: 150px;
margin-bottom: 10px;
overflow-x: auto;
overflow-y: auto;
}
</style>
<script type="application/javascript">
$(function() {
$( ".skills" ).autocomplete({
source: '<?php echo base_url() ?>'+'/controler_name/function_name',
})
$( ".skills" ).autocomplete("widget").addClass("fixedHeight");
});
</script>
<?php
//in controller
// function name(create you own function name and setup)
public function userautocompltedservices(){
$term = $this->input->get('term',true);
$query = $this->db->select('servicename')->from('serviceslist')
->where("servicename LIKE '%$term%'")->get();
$datas = $query->result_array();
foreach($datas as $dat){
$data[] = $dat['servicename'];
}
echo json_encode($data);
}
?>
JQuery Autocomplete example in Codeingniter fully example
Hello here simple example to autocomplete setup in codegniter
sample code to use it.
<input type="text" class="form-control skills" name="name" placeholder="Type Name" />
<style>
.fixedHeight {
font-size:10px;
max-height: 150px;
margin-bottom: 10px;
overflow-x: auto;
overflow-y: auto;
}
</style>
<script type="application/javascript">
$(function() {
$( ".skills" ).autocomplete({
source: '<?php echo base_url() ?>'+'/controler_name/function_name',
})
$( ".skills" ).autocomplete("widget").addClass("fixedHeight");
});
</script>
<?php
//in controller
// function name(create you own function name and setup)
public function userautocompltedservices(){
$term = $this->input->get('term',true);
$query = $this->db->select('servicename')->from('serviceslist')
->where("servicename LIKE '%$term%'")->get();
$datas = $query->result_array();
foreach($datas as $dat){
$data[] = $dat['servicename'];
}
echo json_encode($data);
}
?>
JQuery Autocomplete example in Codeingniter fully example
No comments:
Post a Comment
Thank You For Comment