Forms >>> Option Search.
 
Script Categories













Forms >>> Option Search.

Allows you to jump to any value in a drop down list. In our example, search for a value between 'a1' and 'a15'. Saves time when it comes to navigating within long pull down menus.

Add the below code to the <body> section of your page:

<script language="javascript" type="text/javascript">
/* Visit http://www.yaldex.com/ for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin
function promptSearch (thisform, thisfield) {
var elnum = parseInt(-1);
var k = parseInt(-1);
for (var j = 0; j < document.forms[thisform].elements.length; j++) {
if (document.forms[thisform].elements[j].name == thisfield) {
elnum = j;
break;
   }
}
var myvar = "";
var srch = "";
var menuLength = "";
menuLength = eval("document." + thisform + "." + thisfield + ".length");
srch = prompt("Search this menu for...", "");
if (srch ) {
srch = srch.toUpperCase();
for (var i = 0; i < menuLength; i++) {
myvar = eval("document." + thisform + "." + thisfield + ".options[" + i + "].text.toUpperCase()");
if (myvar.indexOf(srch) >= 0) {
document.forms[thisform].elements[elnum].options[i].selected = true;
break;
      }
   }
}
return false;
}
//  End -->
</script>
<form name=myform action="">
<select
name=menu1 size=1 onFocus="promptSearch(this.form.name, this.name)">
<option>
a1
<option>a2
<option>a3
<option>a4
<option>a5
<option>a6
<option>a7
<option>a8
<option>a9
<option>a10
<option>a11
<option>a12
<option>a13
<option>a14
<option>a15
</select>
</form>

JavaScript Editor Get Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.



Code was highlighted by 1st JavaScript Editor (The Best JavaScript Editor!).

Информация http://www.best4me.info/ на сайте.


©