som på:
http://javascript.internet.com/forms/option-search.htmlDesværre er Promt ikke så sejt mere på, ved ikke om du deler min opfattelse.
Men man vil kunne ændre det til et inputfelt, som du forslår:
<!-- TWO STEPS TO INSTALL OPTION SEARCH:
1. Copy the coding into the HEAD of your HTML document
2. Add the last code into the BODY of your HTML document -->
<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Darko Egersdorfer (darkoe@za.bynx.com) -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!!
http://javascript.internet.com -->
<!-- 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...", "");
srch = eval("document." + thisform + ".Q.value");
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>
</HEAD>
<!-- STEP TWO: Copy this code into the BODY of your HTML document -->
<BODY>
<center>
<form name=myform action="">
<input type="text" value="" name="Q">
<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>
</center>
<p><center>
<font face="arial, helvetica" size"-2">Free JavaScripts provided<br>
by <a href="
http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>
<!-- Script Size: 1.90 KB -->
/def