没找到怎么贴图,不好意思。就是左边一个列表框有几项内容,选中其中几项,点这个按钮>>把所选移到右边列表框。最后把右边列表框的内容更新到数据库,请问用javascript如何实现??

解决方案 »

  1.   

    function SelectUser()
    {
    var addOption=document.createElement("option");
    var index1;
    if(document.Form1.lstAllUser.length==0)return(false);
    index1=document.Form1.lstAllUser.selectedIndex; 
    if(index1<0)return(false);
    addOption.text=document.Form1.lstAllUser.options(index1).text;
    addOption.value=document.Form1.lstAllUser.value;
    if(document.Form1.lstSelectUser.contains(addOption)) return false;
    document.Form1.lstSelectUser.add(addOption);
    document.Form1.txtID.value = document.Form1.txtID.value + addOption.value + ",";
    document.Form1.txtName.value = document.Form1.txtName.value + addOption.text + ",";
    document.Form1.lstAllUser.remove (index1);
    }

    function SelectAllUser()
    {
    for(index = document.Form1.lstAllUser.length -1 ;index >= 0  ; index --)
    {
    var addOption=document.createElement("option");
    addOption.text=document.Form1.lstAllUser.options(index).text;
    addOption.value=document.Form1.lstAllUser.options(index).value;

    document.Form1.lstSelectUser.add(addOption);
    document.Form1.txtID.value = document.Form1.txtID.value + addOption.value + ",";
    document.Form1.txtName.value = document.Form1.txtName.value + addOption.text + ",";

    document.Form1.lstAllUser.remove (index);
    }
    }

    function UnSelectUser()
    {
    var addOption=document.createElement("option");
    var index1;
    if(document.Form1.lstSelectUser.length==0)return(false);
    index1=document.Form1.lstSelectUser.selectedIndex; 
    if(index1<0)return(false);
    addOption.text=document.Form1.lstSelectUser.options(index1).text;
    addOption.value=document.Form1.lstSelectUser.value;
    if(document.Form1.lstSelectUser.contains(addOption)) return false;
    document.Form1.lstAllUser.add(addOption);
    document.Form1.txtID.value = document.Form1.txtID.value.replace(addOption.value + ",","");
    document.Form1.txtName.value = document.Form1.txtName.value.replace(addOption.text + ",","");
    document.Form1.lstSelectUser.remove (index1);
    }

    function UnSelectAllUser()
    {
    for(index = document.Form1.lstSelectUser.length -1 ;index >= 0  ; index --)
    {
    var addOption=document.createElement("option");
    addOption.text=document.Form1.lstSelectUser.options(index).text;
    addOption.value=document.Form1.lstSelectUser.options(index).value;

    document.Form1.lstAllUser.add(addOption);

    document.Form1.txtID.value = document.Form1.txtID.value.replace(addOption.value + ",","");
    document.Form1.txtName.value = document.Form1.txtName.value.replace(addOption.text + ",","");

    document.Form1.lstSelectUser.remove (index);
    }
    }
      

  2.   

    http://lucky.diy.myrice.com/javascriptexam/add_del_Select.htm
      

  3.   

    这样也更新不了数据库 只是看起来是 有什么用牙 推荐使用 AJAX