松鼠的博客

导航

select类

/*
    添加一项
    参数:
        oid:select对象名称
*/

function CSelect(oid)
{
    
this.obj = document.getElementById(oid);
    
this.add = Add;
    
this.clear = Clear;
    
this.selectItem = SelectItem;
}


/*
    添加一项
    参数:
        n:option名
        n:option值
*/

function Add(n,v)
{
    
var item = document.createElement("OPTION");
    
this.obj.options.add(item);
    item.innerText 
= n;
    item.value 
= v;
}


/*
    清空所有option项
*/

function Clear()
{
    
this.obj.options.length = 0;
}

/*
    选择某项
*/

function SelectItem(s)
{
    
this.obj.selectedIndex = s;
}

posted on 2007-12-14 17:22  Xproer-松鼠  阅读(220)  评论(0)    收藏  举报