This effect is very simple.
[Javascript]
<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 )! =-1 ){
Document. getElementById (listBoxID). options [iIndex]. selected = true;
// IStopFlag = 0;
}
IIndex ++;
}
}
}
</Script>
Front-end code:
[Html]
<Table>
<Tr>
<Td>
<Div style = "margin-top: 0; text-align: right">
Locate the merchant (enter the merchant name ):
<Asp: TextBox ID = "txtLocateAllSeller" runat = "server" onkeyup = "OnTextChanged ('txtlocateallseller ', 'liboxallsellers')"> </asp: TextBox> </div>
</Td>
<Td>
</Td>
<Td>
<Div style = "margin-top: 0; text-align: left">
Locate the merchant (enter the merchant name ):
<Asp: TextBox ID = "txtLocateSelectSeller" runat = "server" onkeyup = "OnTextChanged ('txtlocateselectseller ', 'selectsellers')"> </asp: TextBox> </div>
</Td>
</Tr>
</Table>
The advantage of this js method is a general method. You only need to input the TextBox ID and ListBox ID. Location is also equivalent to fuzzy query.
Author: Chinajiyong