六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 132|回复: 0

两个下拉框 左框添加值右框删除值

[复制链接]

升级  52%

34

主题

34

主题

34

主题

秀才

Rank: 2

积分
128
 楼主| 发表于 2013-2-7 21:12:57 | 显示全部楼层 |阅读模式
<!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>
    <title>Untitled Page</title>
<script language="javascript" type="text/javascript">
// <!CDATA[

function ctl00_content_UserRolesPopup1_Button1_onclick() {
    var listAllRoles = document.getElementById("ctl00_content_UserRolesPopup1_ListAllRoles");
    var listSelectedRoles = document.getElementById("ctl00_content_UserRolesPopup1_ListSelectedRoles");
    for (var i = 0; i < listAllRoles.length; i ++) {
        if (listAllRoles.options[i].selected) {
            var ignore = false;
            for (var j = 0; j < listSelectedRoles.options.length; j ++) {
                if (listSelectedRoles.options[j].text == listAllRoles.options[i].text) {
                    ignore = true;
                    break;
                }
            }
            if (!ignore) {
                var newOption = new Option(listAllRoles.options[i].text, listAllRoles.options[i].value);
                listSelectedRoles.options.add(newOption);
            }
        }
    }
}

function ctl00_content_UserRolesPopup1_Button2_onclick() {
    var listSelectedRoles = document.getElementById("ctl00_content_UserRolesPopup1_ListSelectedRoles");
    var array1 = new Array();
    for (var i = listSelectedRoles.options.length - 1; i >= 0; i --) {
        if (listSelectedRoles.options[i].selected)
            listSelectedRoles.options.remove(i);
    }
}

// ]]>
</script>
</head>
<body>
    <table width="500" border="0" cellpadding="0" cellspacing="1">
        <tr>
            <td>
                <select size="4" name="ctl00$content$UserRolesPopup1$ListSelectedRoles" multiple="multiple"
                    id="ctl00_content_UserRolesPopup1_ListSelectedRoles" style="height: 150px; width: 210px;">
                </select>
            </td>
            <td align="center" style="width: 50px;">
                <input type="submit" name="ctl00$content$UserRolesPopup1$Button1" value="<<"
                    id="ctl00_content_UserRolesPopup1_Button1" style="font-family: SimSun;"  />
                <br />
                <input type="submit" name="ctl00$content$UserRolesPopup1$Button2" value=">>" id="ctl00_content_UserRolesPopup1_Button2"
                    style="font-family: SimSun;"  />
            </td>
            <td align="right">
                <select size="4" name="ctl00$content$UserRolesPopup1$ListAllRoles" multiple="multiple"
                    id="ctl00_content_UserRolesPopup1_ListAllRoles" style="height: 150px; width: 210px;">
                    <option value="0f3e50fb-43e8-42ae-ac58-4f973de15091">Administrators</option>
                    <option value="d259f6d2-84fd-4ed2-bebc-bdbd687da615">Guests</option>
                    <option value="35f4bc1e-4e11-4bc5-ab3a-b53bf471197c">Power Users</option>
                    <option value="e07e0a7f-ea0d-4e1c-86ba-42905ff72a5f">Users</option>
                </select>
            </td>
        </tr>
    </table>
</body>
</html>
以上代码可直接编辑使用!
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表