欢迎光临
我们一直在努力

两个列表匡内容互相挪来挪去的例子(javascript)

建站超值云服务器,限时71元/月

效果见
http://www.e-hld.com/tmp/test.htm

代码:

<html>
<head>
<title></title>
<script language="javascript">
function adduser()
    {
    freelength = document.all.freeid.length;
    for (var i=freelength-1;i>=0;i–)
        {
        if (document.all.freeid.options[i].selected)
            {
            var newtext = document.all.freeid.options[i].text;
            var newvalue = document.all.freeid.options[i].value;
            var nowlength = document.all.nowid.length;
            document.all.nowid.options[nowlength] = new option(newtext,newvalue);
            document.all.freeid.options[i] = null;
            }
        }
    }

function deluser()
    {
    nowlength = document.all.nowid.length;
    for (var i=nowlength-1;i>=0;i–)
        {
        if (document.all.nowid.options[i].selected)
            {
            var newtext = document.all.nowid.options[i].text;
            var newvalue = document.all.nowid.options[i].value;
            var freelength = document.all.freeid.length;
            document.all.freeid.options[freelength] = new option(newtext,newvalue);
            document.all.nowid.options[i] = null;
            }
        }
    }
</script>
</head>
<body bgcolor="#ffffff" >
            <table border="1" cellpadding="3" cellspacing="0" style="border-collapse: collapse" bordercolor="#cccccc" width="100%">
              <tr>
                <td colspan="2">
                  <table width="90%" border="0" cellspacing="0" cellpadding="0" align="center">
                    <tr>
                        <td>
                        <select name="freeid" multiple size="6" style="width:200px">
                        
                            <option value="1">admin</option>
                        
                        </select>
                        </td>
                        <td valign="center" align="center">
                        <input type="button" class="it" value="添加>>" onclick="adduser()"><br><br>
                        <input type="button" class="it" value="<<删除" onclick="deluser()">
                        </td>
                        <td>
                        <select name="nowid" multiple size="6" style="width:200px">
                        
                            <option value="11">ehldcio</option>
                        
                            <option value="15">wanglifeng</option>
                        
                            <option value="16">service</option>
                        
                        </select>
                        </td>
                    </tr>
                  </table>
</body>
</html>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 两个列表匡内容互相挪来挪去的例子(javascript)
分享到: 更多 (0)

相关推荐

  • 暂无文章