<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript">
<!--
function addSrcToDestList() {
destList = window.document.forms[0].destList;
srcList = window.document.forms[0].srcList;
var len = destList.length;
for(var i = 0; i < srcList.length; i++) {
if ((srcList.options[i] != null) && (srcList.options[i].selected)) {var found = false;
for(var count = 0; count < len; count++) {
if (destList.options[count] != null) {
if (srcList.options[i].text == destList.options[count].text) {
found = true;
break;
      }
   }
}
if (found != true) {
destList.options[len] = new Option(srcList.options[i].text);
len++;
         }
      }
   }
}function deleteFromDestList() {
var destList  = window.document.forms[0].destList;
var len = destList.options.length;
for(var i = (len-1); i >= 0; i--) {
if ((destList.options[i] != null) && (destList.options[i].selected == true)) {
destList.options[i] = null;
      }
   }
}
// -->
</SCRIPT>
</head>
<body>
<center>
<form method="POST">
<table bgcolor="#FFFFCC"><tr>
<td bgcolor="#FFFFCC" width="85">
<select size="6" name="srcList" multiple>
<option value="1">Item 1
<option value="2">Item 2
<option value="3">Item 3
<option value="4">Item 4
<option value="5">Item 5
<option value="6">Item 6
</select>
</td>
<td bgcolor="#FFFFCC" width="74" align="center">
<input type="button" value=" 增加到右边 " onClick="javascript:addSrcToDestList()">
<br><br>
<input type="button" value=" 从右边删除 " onclick="javascript:deleteFromDestList();">
</td>
<td bgcolor="#FFFFCC" width="69">
<select size="6" name="destList" multiple>
</select>
</td>
</tr>
</table>
</form>
</body>
</html>

解决方案 »

  1.   

    onclick="textf2Name.value=textf1Name.value"
      

  2.   

    我是这样写的,为什么不行呢
    select,select2,select3,textfield是下拉选择框,和文本框。function addtodestlist() {
    destlist = window.document.forms[0].destlist;
    var select=window.document.forms[0].select;
    var select2=window.document.forms[0].select2;
    var select3=window.document.forms[0].select3;
    var str=select.value+select2.value+select3.value;
    var len = destlist.length;
    destlist.options[0] = new Option(str);}
      

  3.   

    不过,怎样获得select控件的值不是value,是显示在select里面的那个值。
    好像不是text,是什么?
      

  4.   

    document.formName.listName.options[document.formName.listName.selectedIndex].value
    document.formName.listName.options[document.formName.listName.selectedIndex].text
      

  5.   

    document.formName.listName[document.formName.listName.selectedIndex].outText