左边select内容选择到右边select内容里面的js实现方法(可以多选和全选)
来源:互联网 发布:Linux用Vim替代字符 编辑:程序博客网 时间:2024/05/16 20:28
<script language="JavaScript">
function copyToList(from,to) //from表示:包含可选择项目的select对象名字 to表示:列出可选择项目的select对象名字
//你可以根据你的具体情况修改
{
fromList = eval('document.forms[0].' + from);
toList = eval('document.forms[0].' + to);
if (toList.options.length > 0 && toList.options[0].value == 'temp')
{
toList.options.length = 0;
}
var sel = false;
for (i=0;i<fromList.options.length;i++)
{
var current = fromList.options[i];
if (current.selected)
{
sel = true;
if (current.value == 'temp')
{
alert ('你不能选择这个项目!');
return;
}
txt = current.text;
val = current.value;
toList.options[toList.length] = new Option(txt,val);
fromList.options[i] = null;
i--;
}
}
}
function allSelect() //这是当用户按下提交按钮时,对列出选择的select对象执行全选工作,让递交至的后台程序能取得相关数据
{
List = document.forms[0].chosen;
if (List.length && List.options[0].value == 'temp') return;
for (i=0;i<List.length;i++)
{
List.options[i].selected = true;
}
}
function copyAll(from,to){
var fromList = eval('document.forms[0].' + from);
var toList = eval('document.forms[0].' + to);
if (toList.options.length > 0 && toList.options[0].value == 'temp')
{
toList.options.length = 0;
}
for (i=0;i<fromList.options.length;i++)
{
var current = fromList.options[i];
toList.options[toList.length] = new Option(current.text,current.value);
fromList.options[i] = null;
i--;
}
}
</script>
<table border="0"> <form onSubmit="allSelect()">
<tr>
<td>
<select name="possible" size="4"
MULTIPLE width=200 style="width: 200px">
<option value="1">中国广州
<option value="2">中国上海
<option value="3">中国北京
<option value="4">中国武汉
</select>
</td>
<td><a href="javascript:copyToList('possible','chosen')">添加至右方--></a><br>
<br>
<a href="javascript:copyAll('possible','chosen')">添加All至右方--></a>
<br><br>
</a><a href="javascript:copyToList('chosen','possible')"><--添加至左方
</a><br><br> </a><a href="javascript:copyAll('chosen','possible')"><--添加All至
左方</a>
<br></td>
<td>
<select name="chosen" size="4"
MULTIPLE width=200 style="width: 200px;">
<option value="temp">从左边选择你的地区
</select>
</td>
</tr> </form>
</table>
function copyToList(from,to) //from表示:包含可选择项目的select对象名字 to表示:列出可选择项目的select对象名字
//你可以根据你的具体情况修改
{
fromList = eval('document.forms[0].' + from);
toList = eval('document.forms[0].' + to);
if (toList.options.length > 0 && toList.options[0].value == 'temp')
{
toList.options.length = 0;
}
var sel = false;
for (i=0;i<fromList.options.length;i++)
{
var current = fromList.options[i];
if (current.selected)
{
sel = true;
if (current.value == 'temp')
{
alert ('你不能选择这个项目!');
return;
}
txt = current.text;
val = current.value;
toList.options[toList.length] = new Option(txt,val);
fromList.options[i] = null;
i--;
}
}
}
function allSelect() //这是当用户按下提交按钮时,对列出选择的select对象执行全选工作,让递交至的后台程序能取得相关数据
{
List = document.forms[0].chosen;
if (List.length && List.options[0].value == 'temp') return;
for (i=0;i<List.length;i++)
{
List.options[i].selected = true;
}
}
function copyAll(from,to){
var fromList = eval('document.forms[0].' + from);
var toList = eval('document.forms[0].' + to);
if (toList.options.length > 0 && toList.options[0].value == 'temp')
{
toList.options.length = 0;
}
for (i=0;i<fromList.options.length;i++)
{
var current = fromList.options[i];
toList.options[toList.length] = new Option(current.text,current.value);
fromList.options[i] = null;
i--;
}
}
</script>
<table border="0"> <form onSubmit="allSelect()">
<tr>
<td>
<select name="possible" size="4"
MULTIPLE width=200 style="width: 200px">
<option value="1">中国广州
<option value="2">中国上海
<option value="3">中国北京
<option value="4">中国武汉
</select>
</td>
<td><a href="javascript:copyToList('possible','chosen')">添加至右方--></a><br>
<br>
<a href="javascript:copyAll('possible','chosen')">添加All至右方--></a>
<br><br>
</a><a href="javascript:copyToList('chosen','possible')"><--添加至左方
</a><br><br> </a><a href="javascript:copyAll('chosen','possible')"><--添加All至
左方</a>
<br></td>
<td>
<select name="chosen" size="4"
MULTIPLE width=200 style="width: 200px;">
<option value="temp">从左边选择你的地区
</select>
</td>
</tr> </form>
</table>
- JS左边select内容选择到右边select内容里面的js实现方法(可以多选和全选)
- 左边select内容选择到右边select内容里面的js实现方法(可以多选和全选)
- 左边select内容选择到右边select内容里面的js实现方法(可以多选和全选)
- 左边select内容选择到右边select内容里面的js实现方法(可以多选和全选)
- 左边select添加到右边select框
- jQquery实现从左边select框添加到右边,并且可以上下排序
- js获取select的内容和vlaue
- 横向滑动ViewGoup(左边菜单右边内容)效果的实现
- 在Linux vim编辑器中实现左边目录,右边内容布局的方法。
- 用javascript实现select全选和取消选择的功能.
- 左边菜单,右边内容
- 左边菜单,右边内容
- select选择框切换内容显示的两种方法
- select标签左边集合和右边集合 ,添加,移除, 多选添加,移除功能
- 原生js实现对select下拉列表的内容过滤
- 左边添加项到右边的JS实现
- JS-点击隐藏显示div里面的内容和改变左边icon
- js获取select当前选项的内容
- python多线程XML-RPC的实现
- 多选列表框动态添加,移动,删除,全选 等操作(完整实例)
- java1.5 Applet数字签名
- zz[Java基础]class.forName().newInstance
- Visual studio 2005 静态页面生成法助E8.Net工作流应用系统提升性能(E8.Net工作流应用系统优化系列二)
- 左边select内容选择到右边select内容里面的js实现方法(可以多选和全选)
- Linux内核配置系统浅析
- VSS与VS2003,VS2005的集成整合
- GridView实现多选操作以及全选或者全不选
- JS的流程设计器,我们需要什么
- 80后的27个典型特征
- dropdownlist中动态添加选项
- 中华人民共和国劳动合同法
- ASP.NET技术的学习顺序问题