用Javascript去除(或隐藏)DropDownList拼音检索后首字母不符合的选项,对Javascript的不是很了解,请大家帮忙解决
------解决方案--------------------------------------------------------
var selects=document.getelementbyid("id");
for(var i=0;i<selects.options;++i)
{
if(selects.options[i]=="xxx")
{
selects.remove(i);
}
}
试下大概这样子.
------解决方案--------------------------------------------------------
var drp2 = document.getElementById( "<%=DropDownList2.ClientID%> ");
for(var i = 0;i <=drp2.options.length -1;i++)
{
drp2.remove(i);
}
------解决方案--------------------------------------------------------
var ddl = document.getElementById("droplistId")
for (var i = 0; i < ddl.options.length; i++) {
if (ddl.options[i].text == 'aaa')
{
ddl.options[i] = null;
}
}
------解决方案--------------------------------------------------------
[code=JScript]
function remove_val(value)
{
var o_sel=document.getElementById("sel");//dropdownlist的id
for(var i=0;i<o_sel.options.length;i++)
{
if(value==o_sel.options[i].value.substring(0,1))
{
o_sel.removeChild(o_sel.options[i]);
o_sel.selectIndex=0;
break;
}
}
}
[/code]