求一个渐进式匹配控件。例如有3个数据,1880,1980,1981,1982,2001,2002,2003。
那么我在TextBox里面输入1的时候,就会自动匹配1880。如果我输入19的时候,就会自动匹配1980。
------解决方案--------------------------------------------------------
javascript可以做到,给你写个简单的例子:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN ">
<html>
<head>
<title> </title>
<meta name= "GENERATOR " content= "Microsoft Visual Studio .NET 7.1 ">
<meta name= "ProgId " content= "VisualStudio.HTML ">
<meta name= "Originator " content= "Microsoft Visual Studio .NET 7.1 ">
<meta name= "vs_targetSchema " content= "http://schemas.microsoft.com/intellisense/ie5 ">
<script language= "javascript ">
<!--
function matchText(){
var txt = new Array( '1880 ', '1980 ', '1981 ', '1982 ', '2001 ', '2002 ', '2003 ');
var obj = document.getElementById( 'txtInput ');
var inputVal = obj.value;
for(var i=0; i <txt.length; i++){
if( inputVal.length < txt[i].length ){
if( txt[i].substr(0, inputVal.length) == inputVal ){
obj.value = txt[i];
break;
}
}
}
}
function bindEvent(){
document.getElementById( 'txtInput ').onkeyup = matchText;
}
window.onload = bindEvent;
//-->
</script>
</head>
<body>
<input type= "text " id= "txtInput ">
</body>
</html>
------解决方案--------------------------------------------------------
从后台动态发出这个脚本就行了。
var txt = new Array( '1880 ', '1980 ', '1981 ', '1982 ', '2001 ', '2002 ', '2003 ');
以上后台动态生成