html
<asp:DropDownList runat="server" CssClass="addddl180" ID="ddlOrderType">
</asp:DropDownList>运营商:<input name="txtOperatorKeyWord" type="text" id="txtOperatorKeyWord" class="addinpu160" />
<input name="btnSearchOperator" onclick="SetOperatorSelect();" class="tbtn" type="button" value=" 搜索 " />
<select id="ddlTemp" style="display:none"></select>
js
function SetOperatorSelect()
{
var objSelect=document.getElementById('ddlOrderType');
var myOperatorKeyWord=document.getElementById('txtOperatorKeyWord').value;
SetValueSelect(objSelect,myOperatorKeyWord);
}
function SetValueSelect(objSelect,myKeyWord)
{
var myTemp=document.getElementById('ddlTemp');
myTemp.options.length=0;
if(myKeyWord!="")
{
for (var i = 0; i < objSelect.options.length; i++) {
if (objSelect.options[i].text.indexOf(myKeyWord)> -1) {
myTemp.options.add(new Option(objSelect.options[i].text,objSelect.options[i].value));
}
}
objSelect.options.length=0;
for (var i = 0; i < myTemp.options.length; i++) {
objSelect.options.add(new Option(myTemp.options[i].text,myTemp.options[i].value));
}
}
else
{
alert("请先输入关键字!");
}
}