Js对SELECT的操作

//对select的options集合操作    
枚举元素除了[]外,SelectName.options.item()也是可以的, 另外SelectName.options.length, 
SelectName.options.add
/remove都可以在两种浏览器上使用。   
注意在add后赋值元素,否则会失败   
动态删除select中的所有options:    
       document.getElementById(
"ddlResourceType").options.length=0;    
动态删除select中的某一项option:    
       document.getElementById(
"ddlResourceType").options.remove(indx);     
动态添加select中的项option:    
       document.getElementById(
"ddlResourceType").options.add(new Option(text,value));    
IE FF 动态删除通用方法:   
document.getElementById(
"ddlResourceType").options[indx] = null;   

posted @ 2011-01-12 09:33  Xia.CJ  阅读(456)  评论(0编辑  收藏  举报