JS二级联动多选框

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript">
<!--
function addSrcToDestList() {
destList = window.document.forms[0].destList;
srcList = window.document.forms[0].srcList;
var len = destList.length;
for(var i = 0; i < srcList.length; i++) {
if ((srcList.options[i] != null) && (srcList.options[i].selected)) {
var found = false;
for(var count = 0; count < len; count++) {
if (destList.options[count] != null) {
if (srcList.options[i].text == destList.options[count].text) {
found = true;
break;
}
}
}
if (found != true) {
destList.options[len] = new Option(srcList.options[i].text);
len++;
}
}
}
}
function deleteFromDestList() {
var destList = window.document.forms[0].destList;
var len = destList.options.length;
for(var i = (len-1); i >= 0; i--) {
if ((destList.options[i] != null) && (destList.options[i].selected == true)) {
destList.options[i] = null;
}
}
}

var array=new Array();
array[0]='<option value="系统管理员">系统管理员</option><option value="安检科采煤科长">安检科采煤科长</option>'
array[1]='<option value="安检科科长">安检科科长</option>'
array[2]='<option value="安装队责任人">安装队责任人</option>'
array[3]='<option value="供应科内业科长">供应科内业科长</option><option value="机电科科长">机电科科长</option>'

function change(w){
 str='<select style="width:100;font-size:13px" size="5" name="srcList" multiple οnchange="javascript:addSrcToDestList()">' 
 str+=array[w]
 str+='</select>'
    sList.innerHTML=str
}
</SCRIPT>
</head>

<body>
<center>
<form method="POST">
<table bgcolor="#FFFFCC">
<tr>
<td align="center">
收件人列表:
</td>
<td>
已选收件人:
</td>
</tr>
<tr>
<td bgcolor="#FFFFCC" width="400">
<select style='width:100;font-size:13px' id="subList" size="5" name="subList" multiple οnchange="javascript:change(subList.value);event.cancelBubble=true;return false">
<option value="0">安检科</option>
<option value="1">调度室</option>
<option value="2">培训科</option>
<option value="3">生产科</option>
<option value="4">巷修二队</option>
<option value="5">财务科</option>
</select>
<span id="sList">
<select style='width:100;font-size:13px' size="5" name="srcList" multiple οnchange="javascript:addSrcToDestList()">
</select>
</span>
</td>
<td bgcolor="#FFFFCC" width="69">
<select style='width:100;font-size:13px' size="5" name="destList" multiple>
</select>
</td>
</tr>
<tr>
<td colspan="3" align="center">&nbsp;
</td>
</tr>
<tr>
<td align="center">
<input type="button" value=" 确定 " οnclick="">
</td>
<td>
<input type="button" value=" 从右边删除 " οnclick="javascript:deleteFromDestList();">
</td>
</tr>
</table>
</form>
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值