这个效果很简单,直接上代码
<script type="text/javascript">
function OnTextChanged(textBoxID, listBoxID) {
var inputText = $.trim($("#" + textBoxID.toString()).val());
if (inputText.length != 0) {
for (var i = 0; i < document.getElementById(listBoxID.toString()).options.length; i++) {
document.getElementById(listBoxID).options[i].selected = false;
}
var sInputName = inputText.toUpperCase();
var iStopFlag = -1;
var iIndex = 0;
var sText;
while (iIndex < document.getElementById(listBoxID).options.length && iStopFlag == -1) {
sText = document.getElementById(listBoxID).options[iIndex].text.toUpperCase();
if (sText.indexOf(sInputName