js与select实现左右option的交换删除
2008-03-09 09:51
447 查看
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
function doquanxian()
{
var flags=0;
var selectobj = document.all.myquanxian;
var employename = '<%=employename%>';
text = document.all["allquanxian"].options[document.all["allquanxian"].selectedIndex].text;
value = document.all["allquanxian"].options[document.all["allquanxian"].selectedIndex].value ;
for(var i=0;i<selectobj.length;i++)
{
if(selectobj.options[i].value==value)
{
flags=1;
}
}
if(flags==1)
{
alert(value+"在"+employename+"的权限列表中已存在!");
}
if(flags==0)
{
selectobj.add(document.createElement("option"));
selectobj.options[selectobj.length-1].text=text;
selectobj.options[selectobj.length-1].value=value;
}
}
function watch_del(){ // 删除
document.all.myquanxian.remove(document.all.myquanxian.selectedIndex);
}
</script>
</head>
<body>
<table width="322" border="1">
<tr>
<td width="135" align="center"><%=employename%>的权限</td>
<td width="30"> </td>
<td width="135" align="center">所有权限</td>
</tr>
<tr>
<td height="205">
<select name="myquanxian" size="15">
<option value="a">a</option>
</select>
</td>
<td><input type="submit" name="Submit" value="<<" onclick="doquanxian()">
<br><input type="submit" name="Submit2" value=">>" onclick="watch_del()">
</td>
<td>
<select name="allquanxian" size="15" ondblclick="doquanxian()">
<option value="shenqingren">申请人</option>
<option value="jingbanren">经办人</option>
<option value="fuzeren">负责人</option>
<option value="shenpiren">审批人</option>
</select>
</td>
</tr>
</table>
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
function doquanxian()
{
var flags=0;
var selectobj = document.all.myquanxian;
var employename = '<%=employename%>';
text = document.all["allquanxian"].options[document.all["allquanxian"].selectedIndex].text;
value = document.all["allquanxian"].options[document.all["allquanxian"].selectedIndex].value ;
for(var i=0;i<selectobj.length;i++)
{
if(selectobj.options[i].value==value)
{
flags=1;
}
}
if(flags==1)
{
alert(value+"在"+employename+"的权限列表中已存在!");
}
if(flags==0)
{
selectobj.add(document.createElement("option"));
selectobj.options[selectobj.length-1].text=text;
selectobj.options[selectobj.length-1].value=value;
}
}
function watch_del(){ // 删除
document.all.myquanxian.remove(document.all.myquanxian.selectedIndex);
}
</script>
</head>
<body>
<table width="322" border="1">
<tr>
<td width="135" align="center"><%=employename%>的权限</td>
<td width="30"> </td>
<td width="135" align="center">所有权限</td>
</tr>
<tr>
<td height="205">
<select name="myquanxian" size="15">
<option value="a">a</option>
</select>
</td>
<td><input type="submit" name="Submit" value="<<" onclick="doquanxian()">
<br><input type="submit" name="Submit2" value=">>" onclick="watch_del()">
</td>
<td>
<select name="allquanxian" size="15" ondblclick="doquanxian()">
<option value="shenqingren">申请人</option>
<option value="jingbanren">经办人</option>
<option value="fuzeren">负责人</option>
<option value="shenpiren">审批人</option>
</select>
</td>
</tr>
</table>
</body>
</html>
相关文章推荐
- js实现删除select下拉框对应option(旧版本,现版本可以直接jQuery显示或隐藏,兼容IE)
- 使用js对select动态添加和删除OPTION
- js删除struts1生成的select下的option
- js删除select中重复项的实现代码
- select列表左右内容交换的JS代码,支持同时多选
- JS动态添加与删除select中的Option对象(示例代码)
- 左右两个Select列表框交换数据的JS
- jQuery插件实现select下拉框左右选择_交换内容(multiselect2side) 的一些网站 (有时间整理)
- 左右两个Select列表框交换数据的JS代码,上下左右都可以移动数据,还可以置顶、沉底,相信大家见到过,但觉得挺实用,与大家分享。
- 使用js对select动态添加和删除OPTION示例代码
- 使用js对select动态添加和删除OPTION
- JS实现Select的option上下移动的方法
- select列表内容交换的js实现代码
- 使用js对select动态添加和删除OPTION示例代码
- 左右两个Select列表框交换数据的JS
- 使用js对select动态添加和删除OPTION示例代码
- js 两个 multiple select 添加 删除 option
- select列表内容交换的js实现代码
- JS动态添加与删除select中的Option对象(示例代码)
- js对select动态添加和删除OPTION