RE: [PHP-ES] OT selección de opción en <SELECT>
| From: | Hubert Abasto | Date: | Fri, 19 Apr 2002 16:00:15 +0000 |
| Subject: | RE: [PHP-ES] OT selección de opción en <SELECT> | ||
| References: | 1 | Groups: | php.general.es |
| Request: | Send a blank email to general-es+get-21676@lists.php.net to get a copy of this message | ||
Saludos listeros
Logre encontrar el script adecuado, se los paso por si les hace falta,
saludos y gracias.
/*
I know lots of people have downloaded this, and I still haven't had
anyone tell me they use it.
PLEASE let me know, just a one liner with your website would be great!
************************************
Author: Max Holman <max@blueroo.net>
Date : Sun, 21 Jan 2001
************************************
This function lets users type in letters to select an option in your SELECT
form fields.
Usually the browser only takes notice of single keystrokes and switches to
the first Option that
begins with that letter.
This scripts buffers the users input and compares it against the OPTIONs in
the SELECT field,
choosing the closest match as you type
Cut and Paste this text into your HTML file or into a separate .js file for
inclusion on your site.
Usage: <SELECT onKeyPress = "return shiftHighlight(event.keyCode, this);">
Platform: Only tested on IE5 (Win) - will not work on Netscape
*/
var timerid = null;
var matchString = "";
var mseconds = 1000; // Length of time before search string is reset
function shiftHighlight(keyCode,targ)
{
keyVal = String.fromCharCode(keyCode); // Convert ASCII Code to a
string
matchString = matchString + keyVal; // Add to previously typed characters
elementCnt = targ.length - 1; // Calculate length of array -1
for (i = elementCnt; i > 0; i--)
{
selectText = targ.options[i].text.toLowerCase(); // convert text in
SELECT to lower case
if (selectText.substr(0,matchString.length) ==
matchString.toLowerCase())
{
targ.options[i].selected = true; // Make the relevant OPTION selected
}
}
clearTimeout(timerid); // Clear the timeout
timerid = setTimeout('matchString = ""',mseconds); // Set a new timeout to
reset the key press string
return false; // to prevent IE from doing its own highlight switching
}
> -----Mensaje original-----
> De: Hubert Abasto [mailto:habasto@bcb.gov.bo]
> Enviado el: jueves, 18 de abril de 2002 10:28
> Para: lista@phpes.com
> Asunto: [PHP-ES] OT selección de opción en <SELECT>
>
>
> Saludos cordiales
>
> Disculpen el OT esta es una pregunta de HTML o JScript tal vez?
>
> Estoy haciendo un programa PHP donde hay una lista de
> opciones bastante
> larga en un <SELECT>. Esta lista contiene varios nombres en orden
> alfabético.
>
> Lo que quisiera es poder hacer búsqueda por teclado en la
> lista, por ejemplo
> si presiono A se va a la primera opción que comienza con A, si luego
> presiono B se va a la primera opción que comienza con B, pero
> yo quisiera,
> en este caso, que se vaya a la primera opción que comienza
> con AB y así
> sucesivamente.
>
> Gracias de antemano
>
>
> ---------------------------------------------------------------------
> Archivo On-line: http://www.phpes.com/
> via news: news://news.phpes.com/
> Manual PHP en español: http://www.php.net/manual/es/
> Para dar de baja la suscripción, mande un mensaje a:
> lista-unsubscribe@phpes.com
>