Welcome Guest, Not a member yet? Register   Sign In
Codeigniter - Autocomplete with Jquery (small article)
#5

[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">
&lt;html &gt;
&lt;head&gt;
    &lt;title&gt;&lt;?=$title;?&gt;&lt;/title&gt;
    &lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt;
    &lt;link rel="stylesheet" href="&lt;?=base_url();?&gt;css/common.css" type="text/css" /&gt;
    &lt;link rel="stylesheet" href="&lt;?=base_url();?&gt;css/thickbox.css" type="text/css" /&gt;
    [removed][removed]
    [removed][removed]
    [removed][removed]
    [removed][removed]
    [removed][removed]
&lt;/head&gt;

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]


Messages In This Thread
Codeigniter - Autocomplete with Jquery (small article) - by El Forum - 01-25-2009, 06:34 AM
Codeigniter - Autocomplete with Jquery (small article) - by El Forum - 01-27-2009, 04:35 PM
Codeigniter - Autocomplete with Jquery (small article) - by El Forum - 01-28-2009, 06:22 AM
Codeigniter - Autocomplete with Jquery (small article) - by El Forum - 01-28-2009, 11:31 AM
Codeigniter - Autocomplete with Jquery (small article) - by El Forum - 01-28-2009, 03:07 PM
Codeigniter - Autocomplete with Jquery (small article) - by El Forum - 01-29-2009, 03:34 AM
Codeigniter - Autocomplete with Jquery (small article) - by El Forum - 01-31-2009, 12:28 PM
Codeigniter - Autocomplete with Jquery (small article) - by El Forum - 01-31-2009, 01:47 PM
Codeigniter - Autocomplete with Jquery (small article) - by El Forum - 01-31-2009, 02:59 PM
Codeigniter - Autocomplete with Jquery (small article) - by El Forum - 07-03-2009, 08:20 PM
Codeigniter - Autocomplete with Jquery (small article) - by El Forum - 07-04-2009, 12:29 AM
Codeigniter - Autocomplete with Jquery (small article) - by El Forum - 09-24-2009, 12:49 AM
Codeigniter - Autocomplete with Jquery (small article) - by El Forum - 09-27-2009, 03:38 PM
Codeigniter - Autocomplete with Jquery (small article) - by El Forum - 01-21-2010, 03:16 PM
Codeigniter - Autocomplete with Jquery (small article) - by El Forum - 04-28-2010, 04:27 AM
Codeigniter - Autocomplete with Jquery (small article) - by El Forum - 09-14-2010, 01:19 AM
Codeigniter - Autocomplete with Jquery (small article) - by El Forum - 08-19-2011, 08:48 AM
Codeigniter - Autocomplete with Jquery (small article) - by El Forum - 08-19-2011, 02:08 PM



Theme © iAndrew 2016 - Forum software by © MyBB