rauljungle
New Member
I'm new to javascript and i tried to follow this tutorial.I have a textbox(input) and i want to use the jquery's autocomplete by loading some data from mysql.This is my controller code :\[code\]public function autocomplete() { if($this->input->post('txt_nama')) $this->absensi_m->get_umat($this->input->post('txt_nama')); /*if (isset($_GET['term'])){ $q = strtolower($_GET['term']); $this->absensi_m->get_umat($q); }*/}\[/code\]This is my model :\[code\]public function get_umat($word) { $this->db->select('nama', 'tanggal_lahir'); $this->db->like('nama', $word); $query = $this->db->get('msumat'); if($query->num_rows() > 0) { foreach($query->result_array() as $row) { $new_row['label'] = htmlentities(stripslashes($row['nama'])); $new_row['value'] = htmlentities(stripslashes($row['tanggal_lahir'])); //build array $row_set[] = $new_row; } echo json_encode($row_set); }}\[/code\]And this is my javascript :\[code\]<script type="text/javascript"> $(function(){ $("#txt_nama").autocomplete({ source: "autocomplete" }); }); </script>\[/code\]I tried to inspect the javascript by using firefox's firebug and GC's developer tool, and this is what i got :\[code\]<input type="text" id="txt_nama" name="txt_nama" class="ui-autocomplete-input" autocomplete="off">\[/code\]Notice that the autocomplete is off. I guess this is the problem so i tried to turn it on by adding this code :\[code\]$(document).ready(function() { $("#txt_nama").attr("autocomplete", "on"); });\[/code\]The autocomplete element is turned on when i add this code, but the autocomplete is still not working.What am i missing?Thanks