两个select通过js 进行数据交换

<script language="javascript">
/**
* moveSelections动态交换多选列表全部数据
* @param arg0 数据来源
* @param rag1 交换对象
*/
function moveSelections(arg0, arg1) {
for (var i=0; i<arg0.options.length; i++) {
var op = arg0.options[i];
arg1.options.add(new Option(op.text, op.value));
arg0.remove(i);
i = i-1;
}
}
/**
* moveSelected动态交换多选列表选择的数据
* @param arg0 数据来源
* @param rag1 交换对象
*/
function moveSelected(arg0, arg1) {
for (var i=0; i<arg0.options.length; i++) {
if (arg0.options[i].selected) {
var op = arg0.options[i];
arg1.options.add(new Option(op.text, op.value));
arg0.remove(i);
i = i-1;
}
}
}
</script>

<body>
<form name="" method="post" action="" οnsubmit="window.close();">
<table width="150" height="250" border="0" align="center">
<tr style="height: 90%">
<td width="48%" class="txtd">
<select name="menuNotInRole" size="12" multiple id="menuNotInRole" style="width:100px;height:100%;" οndblclick="moveSelected(document.getElementById('menuNotInRole'), document.getElementById('infoRole.menu_ids'))">
<option value="1">现场经理</option>
<option value="2">省公司人员</option>
<option value="3">测试执行人员</option>
<option value="4">集成商人员</option>
</select>
</td>
<td>
<input type="button" value=">>" onClick="moveSelected(document.getElementById('menuNotInRole'), document.getElementById('infoRole.menu_ids'))"></input><br /><br />
<input type="button" value="<<" onClick="moveSelected(document.getElementById('infoRole.menu_ids'), document.getElementById('menuNotInRole'))"></input>
</td>
<td width="48%" class="txtd">
<select name="infoRole.menu_ids" size=12 multiple id="infoRole.menu_ids" style="width:100px;height:100%;" οndblclick="moveSelected(document.getElementById('infoRole.menu_ids'), document.getElementById('menuNotInRole'))">
<option value="5">项目经理</option>

</select></td>
</tr>
<tr>
<td colspan="3" align="center">
<input type="submit" value="确定" ></input> <input type="reset" value="取消" />
</td>
</tr>
</table>
</form>
</body>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值