Puo' essere fatto cosi.... (solo x IE)
codice:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<script language="JavaScript" type="text/javascript">
<!--
var token = new Array();
token[0] = 'aaa';
token[1] = 'aab';
token[2] = 'aac';
token[3] = 'aba';
token[4] = 'abb';
token[5] = 'abc';
token[6] = 'baa';
token[7] = 'bab';
token[8] = 'bab';
token[9] = 'caa';
function closeDiv() {
document.getElementById('tokenList').style.display='none';
} // function closeDiv()
function showDiv() {
document.getElementById('tokenList').style.display='block';
} // function showDiv()
function populate() {
showDiv();
//
aVal=document.getElementById('inp').value;
if (event.keyCode != 8) {
aVal = aVal + String.fromCharCode(event.keyCode);
} // if (event.keyCode != 8)
document.getElementById('tokenList').innerHTML = "";
for (i=0;i<token.length;i++) {
if ( aVal != null) {
if (token[i].substr(0,aVal.length) == aVal) {
document.getElementById('tokenList').innerHTML += token[i]+'
';
} // if (token[i].substr(0,aVal.length) == aVal)
} else {
document.getElementById('tokenList').innerHTML += token[i]+'
';
} // if ( aVal != null)
} // for (i=0;i<token.length;i++)
if (document.getElementById('tokenList').innerHTML == "") {
closeDiv();
} // if (document.getElementById('tokenList').innerHTML == "")
} // function populate (aVal)
function populate2() {
document.getElementById('tokenList').innerHTML = "";
for (i=0;i<token.length;i++) {
document.getElementById('tokenList').innerHTML += token[i]+'
';
} // for (i=0;i<token.length;i++)
} // function populate (aVal)
//-->
</script>
</head>
<body onfocus="closeDiv()">
<div id="container">
Search for :<input id="inp" type="text" onkeypress ="populate()"
onfocus="showDiv()" >
<div id="tokenList" style="display:none;position:relative;top:0;left:70;background-color:yellow;width:150px"></div>
</div>
<script language="JavaScript" type="text/javascript">
<!--
populate2();
//-->
</script>
</body>
</html>