selectreaduser.js

来自「全方面的OA管理程序代码」· JavaScript 代码 · 共 96 行

JS
96
字号
function addConfirmer() {
    myform = document.userform;
    for (i = 0; i < myform.selectableIDList.options.length; i++) {
        if (myform.selectableIDList.options(i).selected == true) {
	    j = myform.selectedIDList.options.length - 1;
	    for (; j >= 0; j--) {
	 	if (myform.selectableIDList.item(i).value == myform.selectedIDList.item(j).value) {
	 	    break;
	 	}
	    }
	    if (j < 0) {
	        newOpt = new Option(myform.selectableIDList.item(i).text, myform.selectableIDList.item(i).value);
                myform.selectedIDList.add(newOpt);
	    }
	}
    }
}

function removeConfirmer() {
    myform = document.userform;

    myindex = 0;
    for (; myindex < myform.selectedIDList.options.length; myindex++) {
        if (myform.selectedIDList.options(myindex).value == myform.operatorID.value) {
            break;
	}
    }
    if (myindex == myform.selectedIDList.options.length) {
        myindex = -1;
    }

    for (i = myform.selectedIDList.options.length - 1; i >= myindex; i--) {
        if (myform.selectedIDList.options(i).selected == true) {
            myform.selectedIDList.remove(i);
	}
    }
}

function moveUpDn(direction) {
    myform = document.userform;

    myindex = 0;
    for (; myindex < myform.selectedIDList.options.length; myindex++) {
    	var text = myform.selectedIDList.options(myindex).text;
    	if ( text.charAt(0) != '*'){
    		myindex--;
        //if (myform.selectedIDList.options(myindex).value == myform.operatorID.value) {
            break;
	}
    }
    
    if (myindex == myform.selectedIDList.options.length) {
        myindex = -1;
    }

    index = myform.selectedIDList.options.length;
    count = 0;
    for (i = myform.selectedIDList.options.length - 1; i > myindex; i--) {
        if (myform.selectedIDList.options(i).selected == true) {
	    count++;
	    index = i;
	}
    }
    if (count == 1) {	// Select One only
        if (direction < 0 && index > myindex + 1) {		// Up
	    newOpt = new Option(myform.selectedIDList.item(index).text, myform.selectedIDList.item(index).value);
	    newOpt.selected = true;
            myform.selectedIDList.remove(index);
            myform.selectedIDList.add(newOpt, index + direction);
        }
        if (direction > 0 && index < myform.selectedIDList.options.length - 1) { // Down
	    newOpt = new Option(myform.selectedIDList.item(index).text, myform.selectedIDList.item(index).value);
	    newOpt.selected = true;
            myform.selectedIDList.remove(index);
            myform.selectedIDList.add(newOpt, index + direction);
        }
    }
}


function GetUsers()
{
		myform = document.userform;
		myindex=0;
		for (i = myform.selectedIDList.options.length -1; i >= myindex; i--) {
        myform.selectedIDList.options(i).selected = true;
		myform.SelectedUsers.value=myform.SelectedUsers.value +','+ myform.selectedIDList.item(i).value
		}
}

function closewindow(selectusers,strSelectUsers){
	self.opener.document.UserForm.IDList.value=selectusers;
	self.opener.document.UserForm.NameList.value=strSelectUsers;
	self.close();
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?