Visualizzazione dei risultati da 1 a 8 su 8
  1. #1

    combobox e scelta da tastiera

    Ciao a tutti... sicuramente tutti voi avrete notato che nelle combobox selezionando la combo e cliccando una lettera il valore della combo cambia posizionandosi sulla prima parola che inizia per la lettera scelta (se questa esiste). Ora io vorrei far si che cliccando una seconda lettera la combo non punti alla parola che inizia per questa, ma punti alla parola che punti come prima lettera alla sprima cliccata e come seconda alla seconda cliccata.
    Che fatica spiegarlo....
    Sapete aiutarmi?

  2. #2
    up

  3. #3
    Utente di HTML.it L'avatar di Corwin
    Registrato dal
    Jan 2002
    Messaggi
    584
    Bah, non è perfettamente funzionante ma comunque dovrebbe darti uno spunto...

    codice:
    <script>
    var s = new String("");
    function search(o){
    s = s.concat(String.fromCharCode(event.keyCode).toUpperCase());
    for ( x = 0 ; x < o.options.length; x++)
    {
    var found = 0;
    p = new String(o.options(x).text);
    if (s == p.substr(0,s.length).toUpperCase())
    {
    o.selectedIndex = x;
    }
    }
    }
    </script>
    
    <select onkeyup="search(this);">
    etc... ma le cose da sistemare sono ancora parecchie...
    I don't wanna have to shout it out / I don't want my hair to fall out
    I don't wanna be filled with doubt / I don't wanna be a good boy scout
    I don't wanna have to learn to count / I don't wanna have the biggest amount
    I don't wanna grow up

  4. #4
    Utente di HTML.it L'avatar di Xinod
    Registrato dal
    Sep 2000
    Messaggi
    13,649
    codice:
    <html>
    <head>
    <title>by Max Holman 21jan2001</title>
    <script type="text/javascript">
    
    var timerid     = null;
    var matchString = "";
    var mseconds    = 1000;
    
    function shiftHighlight(keyCode,targ){
      keyVal = String.fromCharCode(keyCode);
      matchString = matchString + keyVal;
      elementCnt  = targ.length - 1;
    
      for (i = elementCnt; i > 0; i--){
        selectText = targ.options[i].text.toLowerCase();
        if (selectText.substr(0,matchString.length) == matchString.toLowerCase()){
          targ.options[i].selected = true;
        }
      }
      clearTimeout(timerid);
      timerid = setTimeout('matchString = ""',mseconds);
      return false;
    }
    </script>
    </head>
    <body>
    <center>
    <form name="letteraa">
    <SELECT onKeyPress = "return shiftHighlight(event.keyCode, this);">
    <OPTION>clicca e scrivi le iniziali</OPTION>	 
    <OPTION>abaco</OPTION> 
    <OPTION>abisso</OPTION> 
    <OPTION>abito</OPTION> 
    <OPTION>abuso</OPTION> 
    <OPTION>accento</OPTION>
    <OPTION>accesso</OPTION> 
    <OPTION>acciaio</OPTION> 
    <OPTION>accusa</OPTION> 
    <OPTION>acerbo</OPTION>
    <OPTION>acqua</OPTION>
    <OPTION>adatto</OPTION>
    <OPTION>addio</OPTION>
    </SELECT>
    </form>
    </center>
    </body>
    </html>
    ciao

  5. #5
    L'avevo poi risolto in modo simile, ma vedo che il vostro è un po' più elegante!
    Se volessi aggiungere questa caratteristica ad ogni menu a tendina (con il prototype) come devo fare?

  6. #6
    up

  7. #7

  8. #8
    nulla?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.