[eluser]J. Brenne[/eluser]
Kk here is there orginal script.. or a part of it.
Load the javascript in your header. My Header looks like
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<title><?=$title;?></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="<?=base_url();?>css/common.css" type="text/css" />
<link rel="stylesheet" href="<?=base_url();?>css/thickbox.css" type="text/css" />
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
</head>
My controller looks like:
Code:
function json_name()
{
$q = strtolower($_POST["q"]);
if (!$q) return;
// form dropdown and myql get countries
$countries = $this->map_model->getCountries();
foreach($countries->result() as $country)
{
$items[$country->name] = $country->countryCode;
}
echo "[";
foreach ($items as $key=>$value) {
if (strpos(strtolower($key), $q) !== false) {
echo "{ name: \"$key\", to: \"$value\" }, ";
}
}
echo "]";
}
view
[code]
[removed]
$(function() {
function format(mail) {
return mail.name + " (" + mail.to + ")";
}
$("#airport_name").autocomplete('airport/json_name', {
multiple: false,
parse: function(data) {
return $.map(eval(data), function(row) {
return {
data: row,
value: row.name,
result: row.name
}
});
},
formatItem: function(item) {
return format(item);
}
});
});
[removed]
[code]