Hi Virgil,

Here is some code using jQueryUI's autocomplete widget
[http://www.machpro.fr/ search box]

Javascript
--------

function searchInputSetup(){
    if ($('#search').autocomplete){
        $('#search').autocomplete({
              source: "AutoSuggest.html"
            , autoFocus: true
            , minLength: 3
            , appendTo: "#recherche"
            , html: true
            , delay: 350 // millisecondes avant que la requête ne parte
            , change: searchSubmit
            , select: function(event, ui){
                    $('#search').attr('value', ui.item.value);
                    searchSubmit(event);
                }
            })
        .focus(function(event){$(this).select()});
    }
};


function searchSubmit(event){ // envoie une chaîne de recherche
    searchStart();
    $.ajax({
        url: 'Search.html',
        data: '&mot=' + encodeURIComponent($('#search').val()), // escape()
        success: searchResultsDisplay,
        cache: false
    });
};


VFP
---
* ==================================================
PROCEDURE AutoSuggest && {fr} Trouve les variantes et expressions d'un Mot dans le Thésaurus && simule l'auto-suggestion
LPARAMETERS ;
    tcTyped,; && {en} Typed by user {fr} Tapé par l'utilisateur
tcAlias,; && C : [m.tcTyped] {en} Alias where results should be stored {fr} Alias où ranger les résultats - .T. : {en} return the SELECT-SQL instruction {fr} retourner l'instruction SELECT-SQL
    tnSeconds,; && @ {en} Execution time {fr} Temps d'exécution
    tlProd && [.F.] {en} Working in production {fr} Production

tnSeconds = 0
tlProd = Iif(Pcount() >= 4, Vartype(m.tlProd) == 'L' AND m.tlProd, NOT lDevMode())

LOCAL luResult; && {en} Number of results stored in (m.tcAlias) or SELECT instruction {fr} Nombre de résultats stockés dans (m.tcAlias) ou instruciton SELECT-SQL
, loEnv AS mpnEnv OF mpnDB.prg;
, loAnsi AS abSet OF abDev.prg;
, lcTyped, lnTyped, laTyped[1], lcMot, lcPrems;
, lcFilter, liWord, lcWord;
, lcSelect

loEnv = mpnEnv()

lcTyped = cSingulier(cComparable_MPN(m.tcTyped))
IF NOT Empty(m.lcTyped);
 AND mpnUse('wThesau,wIndex,wMots,BBIB')

    * Tabuler les mots tapés par l'utilisateur
    lnTyped = ALines(laTyped, m.lcTyped, 1, Space(1))

    * Calculer le filtre
    lcFilter = ''
    FOR EACH lcMot IN laTyped
        lcFilter = m.lcFilter + Iif(Empty(m.lcFilter), [], [ AND ]) + [(]
        FOR liWord = 1 TO 8
            lcFilter = m.lcFilter;
                + Iif(m.liWord = 1, '', ' OR ');
                + Textmerge([Mot<<m.liWord>>='<<m.lcMot>>']) && ANSI OFF
        ENDFOR
        lcFilter = m.lcFilter + [)]
    ENDFOR

    lcFilter = Textmerge([Mots = '<<m.lcTyped>>' OR (<<m.lcFilter>>)])

IF Vartype(m.tcAlias) == 'L' AND m.tcAlias && retourner l'instruction SELECT des entrées de Thesaurus

        TEXT TO lcSelect TEXTMERGE NOSHOW FLAGS 1 PRETEXT 3
                SELECT ID, Mots
                FROM wThesau
                WHERE <<lcFilter>>
        ENDTEXT

        RETURN Strtran(cInLineCommentStripped(m.lcSelect), CRLF, Space(1))

    ELSE

        tnSeconds = Seconds()

        * Ajouter les balises <strong>
* Mettre les accents dans la partie matchée
        lcSelect = 'Mot'
        lnTyped = ALines(laTyped, m.tcTyped, 1, Space(1))
        IF m.lnTyped < 4
            lcSelect = 'Mot'
            FOR EACH lcMot IN laTyped
                IF NOT m.lcMot $ 'strong'
lcSelect = Textmerge("Iif(<<cLitteral(cEuroANSI(m.lcMot))>> $ cEuroANSI(Mot), Stuffc(<<m.lcSelect>>, Atc(<<cLitteral(cEuroANSI(m.lcMot))>>, cEuroANSI(<<m.lcSelect>>)), <<Lenc(m.lcMot)>>, <<cLitteral('<strong>' + m.lcMot + '</strong>')>>), <<m.lcSelect>>)")
                ENDIF
            ENDFOR
        ENDIF

#IF .F.
                 , Max(Cast(wMots.ID AS L)) AS lwMots
                , Max(Nvl(wMots.Actif, .F.)) AS lActif
                , Max(Nvl(bbib.bbib_budg, 0)) AS nBBIB_budg
                        LEFT JOIN wMots ON wIndex.ID_rec = wMots.ID
                            LEFT JOIN BBIB ON wMots.ID_BBIB = BBIB.ID
             AND BBIB.Bbib_pweb
            GROUP BY 1,2,3,4
            ORDER BY
                  lActif DESC
                , nBBIB_budg DESC
                , lwMots DESC
                , Mots
#ENDIF

        TEXT TO lcSelect TEXTMERGE NOSHOW FLAGS 1 PRETEXT 3
            SELECT TOP 30
                  Padr(<<m.lcSelect>>, 100) AS _MATCH && 1
                , wThesau.Mot && 2
                , wThesau.ID && 3
, cEuroANSI(wThesau.Mot) = <<cLitteral(m.lcTyped)>> AS lMatchDebut && ANSI OFF plus loin && 4
                , cEuroANSI(wThesau.Mots) AS TRI && 5
            FROM wThesau
            WHERE <<m.lcFilter>>
            GROUP BY 1,2,3,4,5 && nécessaire au HAVING
            HAVING Indexseek(wThesau.ID, .F., 'wIndex', 'ID_thesau')
            ORDER BY lMatchDebut DESC, TRI
        ENDTEXT
* Ajouter un champ de tri sans accent
* Mettre les accents dans la partie matchée

lcSelect = Strtran(cInLineCommentStripped(m.lcSelect), CRLF, Space(1))
        tcAlias = Evl(m.tcAlias, cVFPName(m.tcTyped))
        loAnsi = abSet('ANSI', 'OFF')
        IF m.tlProd
            &lcSelect INTO CURSOR (m.tcAlias)
            luResult = _tally
        ELSE
            luResult = VFPSelectExecute(m.lcSelect, m.tcAlias)
        ENDIF

        tnSeconds = nSeconds(m.tnSeconds)

        RETURN m.luResult
    ENDIF
ELSE
    RETURN -1
ENDIF

Thierry Nivelet
FoxInCloud
Give your VFP app a second life in the cloud
http://foxincloud.com/

Le 01/12/2014 15:46, Virgil Bierschwale a écrit :
There used to be a utility you could get for foxpro that would allow you to
start typing a company name and it would match your keystrokes to help
narrow down the list.

Don't remember the name for it, but I'm wondering if anything like that is
available for php / mysql combination.

As an example, just for the companies starting with the letter M, I have
over 6,000 names so I can't really build a dropdown that would be usable
with what could possibly be several hundred thousand possible names

Any recommendations?

What I would like to see is as a person starts typing Microsoft, the
program would pull up a list that would grow smaller as they type more
letters.

Haven't been able to find it on google, but I'm probably not describing it
right.

Thanks,

Virgil


--- StripMime Report -- processed MIME parts ---
multipart/alternative
   text/plain (text body -- kept)
   text/html
---

[excessive quoting removed by server]

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to