两个列表框中的元素相互移动(源代码)
来源:互联网 发布:淘宝客成功案例 编辑:程序博客网 时间:2024/04/30 21:37
演示地址:http://datuo.roii.net/java/demo/selectToselect.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>移动</title>
<style type="text/css">
form{background:#CCCCCC;
width:500px;
}
td{width:150px;
height:150px;
text-align:center;
}
select{ width:100px;
height:180px;
}
td div{width:100px;
height:150px;
text-align:center;
}
input{width:100px;
height:30px;
margin:5px;
}
</style>
</head>
<body>
<form id="myForm" name="myForm" method="post" action="#">
<table>
<tr>
<td>
<select name="listLeft" id="listLeft" size="10" multiple="multiple" ondblclick="removeOne(listLeftnode,listRightnode);" >
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
<option value="d">d</option>
<option value="e">e</option>
<option value="f">f</option>
<option value="g">g</option>
</select> </td>
<td>
<div>
<input type="button" name="allRightMove" id="allRightMove" value=" >> " onclick="removeAll(listLeftnode,listRightnode);"/><br />
<input type="button" name="rightMove" id="rightMove" value=" > " onclick="removeOne(listLeftnode,listRightnode);"/><br />
<input type="button" name="leftMove" id="leftMove" value=" < " disabled="disabled" onclick="removeOne(listRightnode,listLeftnode);" /><br />
<input type="button" name="allLeftMove" id="allLeftMove" value=" << " disabled="disabled" onclick="removeAll(listRightnode,listLeftnode);" />
</div>
</td>
<td><select name="listRight" size="10" multiple="multiple" id="listRight" ondblclick="removeOne(listRightnode,listLeftnode);">
</select>
</td>
</tr>
</table>
<script type="text/javascript">
var listLeftnode = document.getElementById("listLeft");
var listRightnode = document.getElementById("listRight");
var btallRightMove = document.getElementById("allRightMove");
var btRightMove = document.getElementById("rightMove");
var btLeftMove = document.getElementById("leftMove");
var btallLeftMove = document.getElementById("allLeftMove");
function isEmpty()
{
if(listLeftnode.options.length<1)
{
btallRightMove.setAttribute("disabled","disabled");
btRightMove.setAttribute("disabled","disabled");
}
else
{
btallRightMove.removeAttribute("disabled");
btRightMove.removeAttribute("disabled");
}
if(listRightnode.options.length<1)
{
btallLeftMove.setAttribute("disabled","disabled");
btLeftMove.setAttribute("disabled","disabled");
}
else
{
btallLeftMove.removeAttribute("disabled");
btLeftMove.removeAttribute("disabled");
}
}
function removeOne(beginList, endList)
{
var flag=false;
for(i=beginList.options.length-1; i>=0; i--)
{
if(beginList.options[i].selected)
{ flag=true;
var tempOption = beginList.options[i];
beginList.remove(i);
endList.add(tempOption, endList.last);
}
}
if(!flag)
{
alert("您没有选择,不能移动!!");
}
isEmpty();
}
function removeAll(beginList,endList)
{
for(i=beginList.options.length-1; i>=0; i--)
{
var tempOption = beginList.options[i];
beginList.remove(i);
endList.add(tempOption, endList.first);
}
isEmpty();
}
</script>
</form>
</body>
</html>
- 两个列表框中的元素相互移动(源代码)
- 两个select列表相互移动
- jQuery中将左右两个列表框的内容相互移动
- 列表之间内容相互移动,列表添加元素
- 两个列表项中的内容相互切换
- html 两个多选下拉列表元素互相移动
- 两个列表中元素比较
- 移动数组中的元素
- 用JavaScript实现两个列表框的数据移动
- 两个 下拉列表框 Select 的 Option 互相移动
- 在两个元素间实现"无缝"移动
- 将两个列表元素组成字典
- 顺序表中的元素移动
- Mathematica 处理列表中的元素
- LintCode:删除列表中的元素
- 452删除列表中的元素
- Python 修改列表中的元素
- 删除列表中的重复元素
- 张朝阳:诚惶诚恐才能生存
- 孙正义:亚洲首富日本软银总裁
- 客户端编程--JavaScript(4)
- 程序人生的感悟
- ARP解决方法/工具+真假ARP防范区别方法+ARP终极解决方案
- 两个列表框中的元素相互移动(源代码)
- Ruby的哲学——与Yukihiro Matsumoto的对话
- 磊落
- 一个没有文化根基的民族是没有希望的
- 赠送gmail、遨游邀请
- ASP.NET2.0里的web.config配置接口API
- 送你个金条,祝我的朋友们发大财!
- H.264开源解码器评测(转载)
- 清除了灰鸽子新变种、几个广告程序