var drp2 = document.getElementById( "<%=DropDownList2.ClientID%> "); for(var i = 0;i <=drp2.options.length -1;i++) { drp2.remove(i); }
关键是如何查找方法就是那样了. 估计也没再好的了,建议使用JS现成类库JQUERY不错,操作方便.
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]
for(var i=0;i<selects.options;++i)
{
if(selects.options[i]=="xxx")
{
selects.remove(i);
}
}
试下大概这样子.
for(var i = 0;i <=drp2.options.length -1;i++)
{
drp2.remove(i);
}
估计也没再好的了,建议使用JS现成类库JQUERY不错,操作方便.
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]