department.js
来自「运用JSP+tomcat及各种数据库编辑的一些较常用的应用程序」· JavaScript 代码 · 共 80 行
JS
80 行
function add()
{
var index = document.all.select1.selectedIndex;
if(index!=-1)
{
var value = document.all.select1.options[index].value;
var item = document.all.select1.options[index].text;
//检查是否有重复的
var bool = 0;
for(var i=0;i<document.all.select2.length;i++)
{
if(document.all.select2.options[i].value==value)
{
bool = 1;
break;
}
}
//添加
if(bool==0)
{
var oOption = document.createElement("OPTION");
document.all.select2.options.add(oOption);
oOption.innerText = item;
oOption.value = value;
}
}
}
function del()
{
var index = document.all.select2.selectedIndex;
if(index==-1)return;
document.all.select2.options.remove(index);
}
function addall()
{
//清空已选列表
//var length = document.all.select2.length;
//for(var i=0;i<length;i++)
//{
//document.all.select2.options.remove(0);
//}
//添加全部列表
for(var i=0;i<document.all.select1.length;i++)
{
var item = document.all.select1.options[i].text;
var value = document.all.select1.options[i].value;
//判断重复性
var bool = 0;
for(var j=0;j<document.all.select2.length;j++){
if(document.all.select2.options[j].value==value)
{
bool = 1;
break;
}
}
//添加
if(bool==0)
{
var oOption = document.createElement("OPTION");
document.all.select2.options.add(oOption);
oOption.innerText = item;
oOption.value = value;
}
}
}
function delall()
{
var length = document.all.select2.length;
for(var i=0;i<length;i++)
{
document.all.select2.options.remove(0);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?