两个select的数据项选择

两个选择框,双击一下边的数据项,数据项传入另一选择框


<html>
<head>
<script type="text/javascript">
function addDbclick1() {
   if(document.all("ListBox1").value==null||document.all("ListBox1").value=="") {
        return false;
    }
    var addOption=document.createElement("option");
    var index;
    if (document.all("ListBox1").length==0) {
        return false;
    } else {
        index=document.all("ListBox1").selectedIndex;
    }
    addOption.text=document.all("ListBox1").options(index).text;
    addOption.value=document.all("ListBox1").options(index).value;

    document.all("ListBox2").add(new Option(addOption.text,addOption.value));

    if(!(index<0)) {
        document.all("ListBox1").options.remove(index);
    }
}

function addDbclick2() {  
    if(document.all("ListBox2").value==null||document.all("ListBox2").value=="") {
        return false;
    }
    var addOption=document.createElement("option");
    var index;
    if(document.all("ListBox2").length==0) {
        return false;
    } else {
        index=document.all("ListBox2").selectedIndex;
    }
    addOption.text=document.all("ListBox2").options(index).text;
    addOption.value=document.all("ListBox2").options(index).value;

    document.all("ListBox1").add(new Option(addOption.text,addOption.value));
    if(!(index<0)) {
        document.all("ListBox2").options.remove(index);
    }
}
</script>
</head>

<body>
<table  border="0" cellpadding="0" cellspacing="0" class="form_info"> 
  <tr>
     <td class="chq_ali4" width="15%" >选择用户</td>
     <td class="chq_ali5"  width="25%">
        <select size="4" id="ListBox1"  onDblClick="addDbclick1();" style="height:260px;width:200px;">
        <option value="1">aaaaa</option>
        <option value="1">bbbbb</option>
        <option value="1">ccccc</option>
        <option value="1">eeeee</option>
        <option value="1">ddddd</option>
        <option value="1">fffff</option>
        <option value="1">sssss</option>
        <option value="1">wwwww</option>
        <option value="1">rrrrr</option>
        </select>
     </td>
    
     <td class="chq_ali5"  width="58%">
        <select name="ListBox2" size="4" id="ListBox2"  onDblClick="addDbclick2();" style="height:260px;width:200px;">
        </select>
        <font color="red">**</font>
     </td>
  </tr>
</table>
</body>
</html>

你可能感兴趣的:(JavaScript,html)