如何在客户端对Web DropDownList控件付值(多值)?或者将数组中的值付给DropDownList控件?谢谢!!

解决方案 »

  1.   

    o = document.getElementById("DropDownList1")
    var a = new Array("1","2")
    for(i = 0;i<a.length;i++)
    o.options[o.options.length] = new Option(a[i],a[i])
      

  2.   

    下面的代码必须放在DropDownList1生成以后:var obj = document.getElementById("DropDownList1");var customOptions = document.createElement("OPTION");  
    customOptions.text = "key1";
    customOptions.value = "value1";obj.add(customOptions);customOptions = document.createElement("OPTION");  
    customOptions.text = "key2";
    customOptions.value = "value2";obj.add(customOptions);