怎么用JavaScript获取DropDownList选中得值,再添加到ListBox中。怎么用JavaScript删除ListBox选中得值!!!

解决方案 »

  1.   

    ListBox生成之后也是一个Select
    DropDownList也是一个Select
    操作它们的options就可以了
      

  2.   

    var select1 = document.all.<%= yourDropDownList.ClientID %>;
    var select1value = select1.options[select1.selectedIndex].value;
    var select1Text = select1.options[select1.selectedIndex].innerText;
    var select2 = document.all.<%= yourListBox.ClientID %>;
    var oOption = document.createElement("OPTION");
    select2.options.add(oOption);
    oOption.innerText = select1Text 
    oOption.Value = select1value ;
      

  3.   

    select2.options.remove(select2.selectedIndex)
      

  4.   

    select2.options.remove(select2.selectedIndex)
      

  5.   

    function test()
    {
    var drp = document.getElementById("DropDownList1");
    var lst = document.getElementById("ListBox1");
    if (drp.length > 0)
    {
    for (i=0; i < drp.options.length; i++)
    {
    if (drp.options(i).selected == true)
    {
    var oOption = document.createElement("OPTION");
    lst.options.add(oOption);
    oOption.innerText  = drp.options(i).innerText;
    oOption.value = drp.options(i).value;
    }
    }
    }
    }function test1()
    {
    var lst = document.getElementById("ListBox1");
    if (lst.length > 0)
    {
    for (i=0; i < lst.options.length; i++)
    {
    if (lst.options(i).selected == true)
    {
    lst.options.remove(i);
    }
    }
    }
    }