您的位置:首页 > Web前端 > JavaScript

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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: