Autocompleted searching script how to use in JavaScript

Hi they all,

I want make autocompleted searching for my site. I find HTML5 autocompleted script in google. I use Laravel and PHP and MongoDB.

My script PHP Code for search autocompleted.

publicfunction searchAutoCompleteAjax(){
$keyword =Input::get('keyword');
$result = array();if(!empty(trim($keyword))){
$mongoResult =MongoDB::instance(true)->collection("items")->like('name',$keyword)->limit(0,10)->fetch();
if($mongoResult){foreach($mongoResult as $key => $item){
$result[]= $item['name'];}}}
echo json_encode(array("error"=>0,"message"=>"Success","result"=>$result));}

I result 10 query

$mongoResult =MongoDB::instance(true)->collection("items")->like('name',$keyword)->limit(0,10)->fetch();

My old javascript code and working for me.
My old javascript code:

function searchAutoComplete(){
    var keyword = $("#search-box").val();
            {"keyword":keyword, "action": "search-auto-complete"},
                response = $.parseJSON(response);
                if(response.error == 0){
                    $.each( response.result , function( key, value ) {
                        $('.autocomplete-suggestions').append('<div class="autocomplete-suggestion" onclick="autoComplateClick('+key+')" id="'+key+'">'+value+'</div>');                      
                    sweetAlert("Hata", response.message, "error");

But i not running in my new javascript code.
My new Java Script Code:

  var currencies = [  ];
  currencies.push('i want query1 this area', 'i want query2 this area', 'i want query3 this area', 'i want query4 this area', 'i want query5 this area', 'i want query6 this area', 'i want query7 this area', 'i want query8 this area', 'i want query9 this area', 'i want query10 this area' );
    lookup: currencies,
    onSelect: function (suggestion) {
    var keywords = suggestion.value;
    //var rkeywords = urlTitle(keywords);
    var rkeywords = keywords.replace(/\ /g,'-').replace(/\//g,'-').replace(/\(/g,'').replace(/\)/g,'');
    location.href = "/arama/"+rkeywords;

i want check query-1, query-2, query-3, … query-10.

Pls help me my old java script code how to apply my new java code?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.