Ajax autocompletion for the impatient

April 14th, 2006 by Tim Leave a reply »

Ajax autocompletion for the impatient has moved here.

Share it:
  • Digg
  • del.icio.us
  • Facebook
  • StumbleUpon
  • LinkedIn
  • Reddit
  • Netvibes
  • Twitthis
  • email
Advertisement

12 comments

  1. CHARIS says:

    I can’t pass the id in the hidden field. I put the function

    function getSelectedId(text, li) {
    $(’customers_fax’).value=li.id;
    }

    before my form, because if I put it after I take error because element getSelectedId is not yet set for the function Ajax.Autocompleter to call it.

    But even I tried all the ways that I can think, I did not managed to get this work, to pass the id in a hidden input field.

    My page code is :

    function getSelectedId(text, li) {
    $(’customers_fax’).value=li.id;
    }

    ÁíáæÞôçóç ÌÝëïõò :

         
         

    new Ajax.Autocompleter(”search”,”hint”,”server.php”,{afterUpdateElement : getSelectedId});

    And my server.php is :

    $test_echo = $_POST['search'];

    $test_echo = str_replace(”A”, “Á”, $test_echo);
    $test_echo = str_replace(”B”, “”, $test_echo);
    $test_echo = str_replace(”G”, “Ô, $test_echo);
    $test_echo = str_replace(”D”, “Ä”, $test_echo);
    $test_echo = str_replace(”E”, “Å”, $test_echo);
    $test_echo = str_replace(”Z”, “Æ”, $test_echo);
    $test_echo = str_replace(”H”, “Ç”, $test_echo);
    $test_echo = str_replace(”U”, “È”, $test_echo);
    $test_echo = str_replace(”I”, “É”, $test_echo);
    $test_echo = str_replace(”K”, “Ê”, $test_echo);
    $test_echo = str_replace(”L”, “Ë”, $test_echo);
    $test_echo = str_replace(”M”, “Ì”, $test_echo);
    $test_echo = str_replace(”N”, “Í”, $test_echo);
    $test_echo = str_replace(”J”, “Δ, $test_echo);
    $test_echo = str_replace(”O”, “Ï”, $test_echo);
    $test_echo = str_replace(”P”, “Д, $test_echo);
    $test_echo = str_replace(”R”, “Ñ”, $test_echo);
    $test_echo = str_replace(”S”, “Ó”, $test_echo);
    $test_echo = str_replace(”T”, “Ô”, $test_echo);
    $test_echo = str_replace(”Y”, “Õ”, $test_echo);
    $test_echo = str_replace(”F”, “Ö”, $test_echo);
    $test_echo = str_replace(”X”, “×”, $test_echo);
    $test_echo = str_replace(”C”, “Ø”, $test_echo);
    $test_echo = str_replace(”V”, “Ù”, $test_echo);

    $keywords = $test_echo;
    $search_name = ” where customers_lastname like ‘%” . $keywords . “%’ or customers_fax = ‘” . $keywords . “‘”;
    $search_name = $db->bindVars($search_name, ‘:keywords:’, $keywords, ‘regexp’);
    $sql = “SELECT customers_fax, customers_lastname, customers_firstname
    FROM customers
    ” . $search_name . ”
    “;

    $rs = mysql_query($sql);

    ?>

    <li id =”" title=”" class=”lista_li”>

    <?php
    echo $data['customers_lastname'].’ ‘.$data['customers_firstname'].’   AM : ‘.$data['customers_fax'].”;
    ?>

    ________________

    I had to search with LATIN characters, because there was a problem with GREEK characters. So when LATIN characters are posted, they are replaced with GREEK characters. And wehen someone wants to search records with LATIN characters in database, he can use lowercase because I replace only upercase characters.

  2. Guille says:

    Hi Tim. I write from Argentina. I´m trying your script, and works fine, but I find a little trouble: in your demo, I can select a suggestions with arrows key + enter, but in my installation I can´t, only allow to select using mouse. Can you giveme a tip to find a solution? I´m using Linux CentOS 5.2 + Apache 2.2 + PHP 5.2 + Last Scriptaculous Library. Too Xampp 1.7 for Windows. Thanks very much in advance.

  3. Joshua says:

    does this script re-query the database with each keystroke or simply complete off of the result data from one query? If it continually queries, you could run into serious memory issues.

    Look forward to your reply

  4. Gokstoola says:

    ckjdsjak96132 sdjhgsjdfvdf buy viagra 68953 45788 bdskcjbds buy viagra online 88606 fdjskv fdvf http://members.ebay.co.uk/ws/eBayISAPI.dll?ViewUserPage&userid=buy_viagra_online buy viagra in UK :) kj cdjhb

  5. Gokstoola says:

    cksdj k jksdkc ksbd84647 kdjc buy viagra 32938 77317 dfcf buy viagra 62865 kjds c http://members.ebay.co.uk/ws/eBayISAPI.dll?ViewUserPage&userid=buy_viagra_online buy viagra :) hjd skc cuckjsd

  6. Thypetrathe says:

    Ты все еще не знаешь где качать бесплатно без кучи рекламы? Проверь здесь =)
    http://www.save-img.com/host/pic_b/d80157d6ced1ae8c33f4714464995c9f.jpg
    хуй ru, группа хуй , дрочить хуй создать сообщение
    ищу секс, секс вечеринка , время секса
    влажная пизда видео, порно фото лохматая пизда , пизда москвы
    между огромных сисек, большие сиськи 3gp , сиськи размер 8
    перис хилтон сосет хуй, анна сосет хуй , самый длиный хуй

  7. laticiajiv says:

    Viagra works in much the same way as Sildenafil Citrate, but is much faster, lasting up to 36 hours For cialis generic sildenafil advice fast delivery Usa.. No prescription required – buy viagra tabs on line! Easy to get sexual health pills online… Find out more about ed at the official vigara generic drugs site..
    ___________________________
    Go to buy buy viagra now…

  8. deenafal says:

    Cheap levitra the prescription erectile dysfunction (ED) tablet clinically proven to both work fast (in as little as 30 minutes for some men) and work up to 36 hours For cialis kamagra fast delivery Europe! No prescription required-buy levitra tabs .. Fast to get erectile dysfunction pills online. Find out more about viagra at the official vigara online usa site…
    ___________________________
    Go to order dosing cials now!

  9. nicholvif says:

    Tadalafil is taken orally and helps men suffering from erectile dysfunction achieve and maintain an erection For viagra generic soft tabs very fast delivery for you! Save your money -buy cialis pill … Easy to get cialis pills online. Find out more about sexual activity at the great calis pfizer site.
    ___________________________
    canadian generic levirta ukonline…

  10. leonardabol says:

    Cheap cialis is taken orally and helps men suffering from erectile dysfunction achieve and maintain an erection For cialis order usa fast delivery Usa. No prescription required -buy priaprism pills now.. Fast to get cialis pills online… Find out more about erectile dysfunction at the great viagara herbal site
    ___________________________
    Buy now canada tadafil …

  11. Heya,

    So I am working on something similar.
    A piece of advice, for the PHP to this:

    instead of writing all those str_replace, either do a for() loop for all latin Char(), or just make an array.

    ie.

  12. Diego Calle says:

    I was just trying your autocompletion demo and it works just fine, but how can I do that when somebody select an option the script fill a hidden input with another info of the same SQL query.

    To be more clare, I need to search by name a database of customers but when I found the person by his name I need to load his identification in a hidden input.

    Thanks for all

Leave a Reply