Ver Mensaje Individual
  #6 (permalink)  
Antiguo 21/11/2004, 19:59
guntin_java
 
Fecha de Ingreso: mayo-2004
Mensajes: 159
Antigüedad: 20 años, 7 meses
Puntos: 0
mil gracias furoya, yo también busqué en la red y encontré esto en hotscripts, creo que sería conveniente que el moderador lo pusiera en las faq, pues allí no hay nada parecido:

Código:
<SCRIPT LANGUAGE="Javascript 1.2" type="text/javascript">
/*

	Please keep the following lines visible, in recognition of my work...

	************************	
	Author: Max Holman <[email protected]>
	Date  : Sun, 21 Jan 2001
	************************

	This functions 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

	}
</SCRIPT>
<SELECT NAME=TEST onKeyPress = "return shiftHighlight(event.keyCode, this);">....