<html>
<head>
<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>
<head>
<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>
我已给分不过我写的JS却不知问题出在哪,孟大哥可否帮我看一下?
<Script language="JavaScript">
//从from_list中的选项转移到to_list
function transform(from_list,to_list){
var from_length=from_list.options.length
var to_length=to_list.options.length
for(var i=0;i<from_length;i++){
if(from_list.options[i].selected){
var str=from_list.options[i].text
to_list.options[to_length++]=new Option(str,str)
from_list.options[i--]=null
}
}
}</Script>
<!-- created by WangCong 2002.06.13 html\public\choose.htm -->
<HTML><HEAD><TITLE>选择</TITLE>
<META content="text/html; charset=GB2312" http-equiv=Content-Type><LINK
href="../../css/style.css" rel=stylesheet type=text/css>
<META content="MSHTML 5.00.2614.3500" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff leftMargin=0 text=#000000 topMargin=0 marginheight="30%"
marginwidth="30%"><Script language="JavaScript">
//从from_list中的选项转移到to_list
function transform(from_list,to_list){
var from_length=from_list.options.length
var to_length=to_list.options.length
for(var i=0;i<from_length;i++){
if(from_list.options[i].selected){
var str=from_list.options[i].text
to_list.options[to_length++]=new Option(str,str)
from_list.options[i--]=null
}
}
}
//将LIST框中的选项向上移动
function up_click(cur_list){
var cur_index=cur_list.selectedIndex
var str=cur_list.options[cur_index].text
cur_list.options[cur_index].text=cur_list.options[cur_index-1].text
cur_list.options[cur_index].value=cur_list.options[cur_index-1].text
cur_list.options[cur_index-1].text=str
cur_list.options[cur_index-1].value=str
cur_list.selectedIndex=cur_index-1
}
//将LIST框中的选项向下移动
function down_click(cur_list){
var cur_index=cur_list.selectedIndex
var str=cur_list.options[cur_index].text
cur_list.options[cur_index].text=cur_list.options[cur_index+1].text
cur_list.options[cur_index].value=cur_list.options[cur_index+1].text
cur_list.options[cur_index+1].text=str
cur_list.options[cur_index+1].value=str
cur_list.selectedIndex=cur_index+1
}
</Script><TABLE border=0 cellPadding=0 cellSpacing=0 width="100%" align="center">
<TBODY>
<TR>
<TD width="100%" align="center"> <BR>
<FORM action=/save.jsp id=form1 method=post name=form1>
<TABLE align=center border=0 width="363">
<TBODY>
<TR>
<TD bgColor=#000066 height="149" >
<TABLE align=center border=0 cellPadding=5 cellSpacing=1
width="100%" height="100%">
<TR bgColor=#ffffff>
<TD width="28%" height="144" align="center" valign="top">
<select name="total" multiple size="10">
<option value="技术部">技术部</option>
<option value="开发部">开发部</option>
<option value="人事部">人事部</option>
</select>
</TD>
<TD height="144" width="20%" align="center">
<p>
<input type="button" value="add" onClick="transform(total,needed)">
</p>
<p>
<input type="button" value="delete" onClick="transform(needed,total)">
</p>
</TD>
<TD align="center" height="144" width="30%" valign="top">
<select name="needed" multiple size="10">
<option value="销售部">销售部</option>
</select>
</TD>
<TD colspan="2" height="144" width="22%" align="center">
<p>
<input type="button" name="up" value="up" onClick="up_click(needed)">
</p>
<p>
<input type="button" name="down" value="down" onClick="down_click(needed)">
</p>
</TD>
</TR>
<TBODY> </TBODY>
</TABLE>
</TD>
</TR></TBODY></TABLE>
<br><div align="center">
<input type="submit" name="Submit2" value="确定" onClick="javascript:window.opener.location.href='6.htm'; window.close()">
<input type="button" name="Submit24" value="取消" onClick="javascript:window.close();">
</div>
</FORM></TD></TR></TBODY></TABLE>
<!--- end buttom --->
</BODY></HTML>
function transform(from_list,to_list){
for(var i=0;i<from_list.options.length;i++){
if(from_list.options[i].selected){
var str=from_list.options[i].text
to_list.options[to_list.options.length++]=new Option(str,str)
from_list.remove(i--)
}
}
}