现在的位置: 首页 > 综合 > 正文

DropDownList一些操作(JS)

2013年02月02日 ⁄ 综合 ⁄ 共 430字 ⁄ 字号 评论关闭

 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));

抱歉!评论已关闭.