DropDownList一些操作(JS)

1.取value值
    var xxlh = new String(document.Form1.XL.value);
2.取text值
    var xxlm
    try
    {
        xxlm = new String(document.Form1.XL.options[document.Form1.XL.selectedIndex].text);
    }
    catche(e)
    {
        alert('XL的text值可能未指定或XL未绑定');
    }
3.按指定索引选择下拉列表
    document.Form1.XL.selectedIndex = 0;
4.按索引移除下拉列表的某一项
    document.Form1.XL.options.remove(document.Form1.XL.length-1);
5.为下拉列表添加一项
    document.Form1.XL.options.add(new Option(text,value));

posted on 2005-12-06 21:59  小肠与小豆子  阅读(864)  评论(0)    收藏  举报

导航