[eluser]goldensona[/eluser]
Hi
Finally i get a autocomplete but some of script codes are display in the textbox while i m searching ,might be my code will be wrong , please correct my code and guide me why this error occur.
this is my view home.php
Code:
[removed][removed]
[removed][removed]
<link rel="stylesheet" type="text/css" href="<?php echo base_url()."jquery-autocomplete/jquery.autocomplete.css"?>" />
[removed]//autocomplete function
$().ready(function() {
function formatItem(row) {
return row[0] ;
}
function formatResult(row) {
return row[0].replace(/(<.+?>)/gi, '');
}
$("#country").autocomplete('searcheasy/index', {
matchContains: true,
minChars: 0,
mustMatch: true,
autoFill: true
});
});
this is my controller searcheasy.php
Code:
function view()
{
$this->load->database();
$this->load->model('dbsearch');
$data = $this->dbsearch->getdata(); //Search DB
foreach($data as $row =>$key)
{
echo $key."\n";
}
}
function index()
{
if(IS_AJAX){
$this->view();
}
}
this is my model dbsearch.php
Code:
var $namearr=array();
function getdata() {
$data=$this->db->get('countrytable');
foreach ($data->result_array() as $row)
{
$id= $row['id'];
$name=$row['countryname'];
$namearr=$this->array_push_assoc($namearr,$id,$name);
}
return $namearr;
}
function array_push_assoc($array, $key, $value)
{
$array[$key] = $value;
return $array;
}
thanks
sona