(高分) 求一个javaScript 代码
大家帮忙写一个javaScript:
页面有两个列表框A,B 和两个Button C(增加) D(删除).
当选中列表框A中的项,点Button C(增加)或者双击该项时,增加到B列表框而
在A列表框中删除.选中B列表框的项,双击或者点Button D(删除).该项增加到A列
表框中.在B列表狂中删除.
不知道叙述清楚没有, 没看清楚请大家提出来
谢谢!
------解决方案-------------------- meizz 梅花雪 的
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN ">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME= "Generator " CONTENT= "EditPlus ">
<META NAME= "Author " CONTENT= " ">
<META NAME= "Keywords " CONTENT= " ">
<META NAME= "Description " CONTENT= " ">
</HEAD>
<table border=0 cellpadding=0 cellspacing=0> <form name=meizz>
<tr> <td>
<select id=list1 size=8 ondblclick= "moveOption(this, this.form.list2) ">
<option value=A> aaaaaaaaaa
<option value=B> bbbbbbbbbb
<option value=C> cccccccccc
<option value=D> dddddddddd
<option value=E> eeeeeeeeee
<option value=F> ffffffffff
<option value=G> gggggggggg
<option value=H> hhhhhhhhhh
</select> </td>
<td width=40 align=center>
<input name=add type=button value= "> > > " onclick= "moveOption(this.form.list1, this.form.list2) "> <br/> <br/>
<input name=sub type=button value= " < < < " onclick= "moveOption(this.form.list2, this.form.list1) ">
</td> <td>
<select id=list2 size=8 ondblclick= "moveOption(this, this.form.list1) ">
</select>
</td> </tr> </form>
</table>
<script language= "JavaScript "> <!--
function moveOption(e1, e2){
try{
var e = e1.options[e1.selectedIndex];
e2.options.add(new Option(e.text, e.value));
e1.options.remove(e1.selectedIndex);
} catch(e){}
}
//--> </script>
<BODY>
</BODY>
</HTML>
------解决方案--------------------梅雪香的:
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> made by meixx </title>
<script language= "javascript ">
<!--
function Add(ObjSource,ObjTarget){
for(var i=ObjSource.length-1;i> =0;i--){
if(ObjSource.options[i].selected){
ObjTarget.add(new Option(ObjSource.options[i].text,ObjSource.options[i].value,true));
ObjSource.options.removeChild(ObjSource.options[i]);
}
}
}
function AddAll(ObjSource,ObjTarget){
SelectAll(ObjSource);
Add(ObjSource,ObjTarget);
}
function SelectAll(ObjSource){
for(var i=0;i <ObjSource.length;i++){
ObjSource.options[i].selected=true;
}
}
function doSubmit(){
SelectAll(frmDisplay.dltTarget);
//frmDisplay.action= " ";//设置form 提交的action
alert(frmDisplay.action);
//frmDisplay.submit();//取消注释即可,提交上去的options
}
//->
</script>
</head>
<body>
<table wid