• javascript实现ListBox左右全选、单选、多选、全请


    <SCRIPT language="javascript">

      //Esc键退出
       function document.onkeydown()
       {
        var k = window.event.keyCode;
        if(k==27)
         window.close();
       }

      </SCRIPT>
      <script language="JavaScript">
      function PostValue()
      {
       var lbobject=document.all.Lb_Object;
       var revalue=new Array();
       var k=-1;
       for(i=0;i<lbobject.options.length;i++)
       {
        revalue[++k] =  lbobject.options[i].text;
        revalue[++k] =  lbobject.options[i].value;
       }
       window.parent.returnValue = revalue;   
       window.close();
       return; 
       
      }

      //移动选中项目
      function MoveSingleItem(sel_source, sel_dest)
       {
          if (sel_source.selectedIndex<0)return;  //源:没有点选任何项目
          var str="";
          var sel_source_len = sel_source.length;
            for(var i=0;i<sel_source_len;i++)
            {
              if(sel_source.options[i].selected)
              {
                 var oOption = document.createElement("OPTION");
                oOption.text=sel_source.options[i].text;
                oOption.value=sel_source.options[i].value;      
                   sel_dest.options.add(oOption);

                   //这里很关键
                   sel_source.options.remove(i);
                   sel_source_len--;
                   i=-1;
              }
            }

              CopyToControl();
                 
       }

      //设置选中项目
       function MoveAllItems(sel_source, sel_dest)
       {      
          var sel_source_len = sel_source.length;
          
          //先复制“源”所有项目:
          for (var j=0; j<sel_source_len; j++)
          {
           var oOption = document.createElement("OPTION");
        oOption.text=sel_source.options[j].text;
        oOption.value=sel_source.options[j].value;      
           sel_dest.options.add(oOption);
          }

          //然后删除“源”所有项目:
          for (var k=0;k<sel_source_len;k++)
          {
            sel_source.options.remove(0);
          }
          
          CopyToControl();
          
       }
       
       function  CopyToControl(){     //复制到其他控件
            var sControl=document.all.txt_ObjectUser;
            sControl.value="";     
         for(var i=0;i<document.all.Lb_Object.length;i++){   //拷贝数据    
         sControl.value=sControl.value+document.all.Lb_Object.options[i].value+',';
         }
       }

       function SelectAll(theSel)  //选中select中全部项目
       {
       for (i = 0 ;i<theSel.length;i++)
           theSel.options[i].selected = true;
       }

     var PageLoadFlag=false;
      //页面加载
      function On_PageLoad(){
       if(PageLoadFlag)return;
       PageLoadFlag=true;
        
        
         <%//如果是第一次则列出原来用户      
          if(!isInitLb_Object){
           Response.Write("InitLb_Object(parent.dialogArguments);");       
          }
          %>  
            
           
        var theSel=document.all["Ddl_Org"];
          var re=/\&amp;/;
         
          //替换字符串
          if(theSel!=null){
        for(i=0;i<theSel.length;i++){
          do{
           var sTem=theSel.options[i].innerHTML;
              theSel.options[i].innerHTML = theSel.options[i].innerHTML.replace("&amp;","&");
             }while(sTem!=theSel.options[i].innerHTML)
           }
          }

       }
       function InitLb_Object(value){
        document.all.Txt_Sel.value=value;
        if(value.length>36)
         window.Form1.submit();
       }


       

  • 相关阅读:
    庆贺发文200篇
    Windows 2003 Server: Background Intelligent Transfer Service service hung on starting异常
    Enterprise Library: Configuration Application Block应用向导篇, Part 3
    Enterprise Library: Configuration Application Block类设计分析篇
    Enterprise Library: Caching Application Block概述
    Enterprise Library: Data Access Application Block类设计分析篇
    Web Parts, Impersonate and Security Policy, Part 3
    MyGeneration 1.1 Released
    Enterprise Library: Logging and Instrumentation Application BlockEmail接收池设计向导篇
    Cool, Enterprise Library released!
  • 原文地址:https://www.cnblogs.com/zhangzt/p/1620829.html
Copyright © 2020-2023  润新知