zoukankan      html  css  js  c++  java
  • 两个列表之间移动数据

    <style type="text/css">

    *{ margin:0px auto; padding:0px; font-family:微软雅黑; font-size:14px;}

    </style>

    </head>

    <body>

    <div style="600px; height:500px; margin-top:20px">

          

        <div style="200px; height:300px; float:left">

        <select id="list1" size="10" style="200px; height:300px">

               <option>山东</option>

            <option>北京</option>

            <option>河北</option>

            <option>黑龙江</option>

            <option>河南</option>

        </select>

        </div>

        <div style="80px; height:300px; float:left">

              

            <input type="button"  value="单移" id="btn1" style="70px; height:30px" onclick="Dan()"/>

             <input type="button"  value="全移" id="btn2" style="70px; height:30px" onclick="Duo()"/>

              

        </div>

        <div style="200px; height:300px; float:left">

         <select id="list2" size="10" style="200px; height:300px">

         </select>

        </div>

       

       

       

    </div>

    function Dan()

    {

           //把列表1选中值取出

           var list1 = document.getElementById("list1");

           var v = list1.value;

          

           //造一个option项

           var s = "<option class='o2'>"+v+"</option>";

          

           //判断list2里面是否有该项

           var attr = document.getElementsByClassName("o2");

           var cz = true;

           for(var i=0;i<attr.length;i++)

           {

                  //alert(attr[i].innerHTML);

                  if(attr[i].innerHTML==v)

                  {

                         cz = false;

                         break;

                  }

           }    

           if(cz)

           {

                  //将option项扔到list2

                  var list2 = document.getElementById("list2");

                  list2.innerHTML +=s;

           }

    }

    function Duo()

    {

          document.getElementById("list2").innerHTML = document.getElementById("list1").innerHTML;

    }

  • 相关阅读:
    numpy学习(将条件逻辑表述为数组运算)
    numpy学习(利用数组进行数据处理)
    numpy学习(通用函数:快速的元素级数组函数)
    numpy学习(数组转置和轴对换)
    numpy学习(花式索引)
    关于C++中的虚拟继承的一些总结
    adb常用命令
    进程隐藏的方法
    Microsoft Detours 2.1简介
    ebay如何确定同一电脑登陆了多个账号,以及同一账号登陆过多台电脑
  • 原文地址:https://www.cnblogs.com/sq45711478/p/5899130.html
Copyright © 2011-2022 走看看