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

<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 728x15, 创建于 08-4-23MSDN */ google_ad_slot = "3624277373"; google_ad_width = 728; google_ad_height = 15; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 160x600, 创建于 08-4-23MSDN */ google_ad_slot = "4367022601"; google_ad_width = 160; google_ad_height = 600; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
效果见
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>


< <script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 728x15, 创建于 08-4-23MSDN */ google_ad_slot = "3624277373"; google_ad_width = 728; google_ad_height = 15; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 160x600, 创建于 08-4-23MSDN */ google_ad_slot = "4367022601"; google_ad_width = 160; google_ad_height = 600; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
阅读更多
个人分类: javascript
想对作者说点什么? 我来说一句

cad绘图工具键

2015年02月06日 74KB 下载

最新的挪顿NOD-32

2009年03月05日 2.77MB 下载

微擎微赞-微信挪车4.0最新版

2018年03月08日 991KB 下载

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭