Jquery's autocomplete documentation seems to be a bit lacking, at least for beginners. I've scoured the net for good tutorials, but haven't found any.
Heres what I have so far:
HTML:
<div id="addfilter">
<div id="textwrap">
<form method="POST" class="homeForm" id="homeForm" action="<?php echo base_url() ?>main/add_filter">
<input type="text" class="text" id="homeText" name="homeText" placeholder="Add Category"></input>
<input type="image" class="imginput" src="<?php echo base_url() ?>img/board/icons/add.jpg"id="homeSubmit" value="X"></input>
</form>
</div>
</div>
JS:
$().ready(function() {
$("text").autocomplete("search.php", {
width: 260,
matchContains: true,
selectFirst: false
});
});
search controller
public function search()
{
$this->thread_model->autocomplete();
}
autocomplete model
public function autocomplete()
{
$query = $this->db->query('SELECT tag
, COUNT(*) as num_items
FROM filter_thread ft
INNER JOIN filter f
ON ft.filter_id = f.filter_id
GROUP BY tag');
$tagcloud = $query->result_array();
foreach ($tagcloud as $tags)
{
echo $tags;
}
}
Firebug doesn't show anything happening when I input text into 'formText.' I'm not even sure if the output of the model is in the correct format. Any help would be appreciated!
LIKE("%'.$this->db->escape($_POST['term']).'%")
part thatin the answer @liaant wrote. – Taha Paksu May 30 '12 at 7:57