I am attempting to search through a DropDownList. The list is populated from the database and not in any explicit front end list. For previous searches, I have used OnKeyUp in a textbox to search through rows. However, in this case there is no search textbox- the search must be done when the user clicks/hovers over the filter. Additionally, and less importantly, the search needs to start after the dash symbol (-) as items in the list start with acronyms as displayed here:
XYZ - Kansas
YBE - Delaware
CIT - New Jersey
The code:
<ASP:DropDownList ID="ddlProgram" AutoPostBack="true" runat="server" />
Any thoughts on this? I found some useful code that may be relevant here but it seems to require a textbox as input and a front end list but the logic seems sound:
function searchSel()
{
var input = document.getElementById('realtxt').value.toLowerCase();
len = input.length;
output = document.getElementById('realitems').options;
for(var i=0; i<output.length; i++)
if (output[i].text.toLowerCase().indexOf(input) != -1 ){
output[i].selected = true;
break;
}
if (input == '')
output[0].selected = true;
}