function copyOption(e1, e2){
try{
var e = e1.options[e1.selectedIndex];
var count=e2.length;
var i;
for(i=count;i>0;i--){
if(e.value!=e2.options[i].value){
e2.options.add(new Option(e.text, e.value));
}else{}
}
}catch(e){}
}
<input type="button" name="copy" value="复制" />
<select name="sel1">
<select name="sel2">
function copyOption(e1, e2){
try{
if(e1.selectedIndex<0)return;
var e = e1.options[e1.selectedIndex];
var tmpvalue=e2.value;//保存e2的值
e2.value=e1.value;//设置e2的值为e1的值
if(e2.selectedIndex== -1 )//如果e2里没有这个值,selectedIndex为-1
e2.options.add(new Option(e.text, e.value));
e2.value=tmpvalue;//恢复e2的值
}
}catch(e){}
}
<html>
<head>
<meta http-equiv="Content-Type" c>
<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){
var opt=document.createElement("OPTION");
ObjTarget.add(opt);
opt.value=ObjSource.options[i].value;
opt.text=ObjSource.options[i].text;
ObjSource.options.removeChild(ObjSource.options[i]);
opt.selected=true;
}
}
/*
for(var i=0;i<ObjSource.length;i++){
if(ObjSource.options[i].selected){
var opt=document.createElement("OPTION");
ObjTarget.add(opt);
opt.value=ObjSource.options[i].value;
opt.text=ObjSource.options[i].text;
ObjSource.options.removeChild(ObjSource.options[i--]);
opt.selected=true;
}
}*/
}
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 width="350" border="1" style="border-collapse:collapse " bordercolor="#111111" cellpadding="0" cellspacing="0">
<tr>
<td width="150">
<select name="dltSource" size="10" multiple style="width:100% ">
<option value="0">辽宁</option>
<option value="0">黑龙江</option>
<option value="0">吉林</option>
<option value="0">河北</option>
<option value="0">河南</option>
<option value="0">江苏</option>
<option value="0">浙江</option>
<option value="0">海南</option>
<option value="0">福建</option>
<option value="0">山东</option>
<option value="0">青海</option>
<option value="0">宁夏</option>
<option value="0">内蒙古</option>
<option value="0">新疆</option>
<option value="0">陕西</option>
</select>
</td>
<td width="50" valign="middle">
<p style="width:100%" align="center"><input type="button" value="->" title="添加"></p>
<p style="width:100%" align="center"><input type="button" value="=>" title="添加全部"></p>
<p style="width:100%" align="center"><input type="button" value="<-" title="删除"></p>
<p style="width:100%" align="center"><input type="button" value="<=" title="删除全部"></p>
</td>
<td width="150">
<form id="frmDisplay" action="xxx.jsp" method="post" style="margin:0 ">
<select name="dltTarget" size="10" multiple style="width:100% "></select>
</form>
</td>
</tr>
<tr>
<td align="center">作者:梅雪香</td>
<td align="center">ver:1.0</td>
<td align="center">
<input type="reset" value="重置">
<input type="button" value="提交" >
</td>
</tr>
</table>
</body>
</html>
try{
var e = e1.options[e1.selectedIndex];
var count=e2.length;
var i;
for(i=count;i>0;i--){
if(e.value!=e2.options[i].value){
e2.options.add(new Option(e.text, e.value));
}else{}
}
}catch(e){}
}
<input type="button" name="copy" value="复制" />
<select name="sel1">
<select name="sel2">
function copyOption(e1, e2){
try{
if(e1.selectedIndex<0)return;
var e = e1.options[e1.selectedIndex];
var tmpvalue=e2.value;//保存e2的值
e2.value=e1.value;//设置e2的值为e1的值
if(e2.selectedIndex== -1 )//如果e2里没有这个值,selectedIndex为-1
e2.options.add(new Option(e.text, e.value));
e2.value=tmpvalue;//恢复e2的值
}
}catch(e){}
}
<html>
<head>
<meta http-equiv="Content-Type" c>
<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){
var opt=document.createElement("OPTION");
ObjTarget.add(opt);
opt.value=ObjSource.options[i].value;
opt.text=ObjSource.options[i].text;
ObjSource.options.removeChild(ObjSource.options[i]);
opt.selected=true;
}
}
/*
for(var i=0;i<ObjSource.length;i++){
if(ObjSource.options[i].selected){
var opt=document.createElement("OPTION");
ObjTarget.add(opt);
opt.value=ObjSource.options[i].value;
opt.text=ObjSource.options[i].text;
ObjSource.options.removeChild(ObjSource.options[i--]);
opt.selected=true;
}
}*/
}
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 width="350" border="1" style="border-collapse:collapse " bordercolor="#111111" cellpadding="0" cellspacing="0">
<tr>
<td width="150">
<select name="dltSource" size="10" multiple style="width:100% ">
<option value="0">辽宁</option>
<option value="0">黑龙江</option>
<option value="0">吉林</option>
<option value="0">河北</option>
<option value="0">河南</option>
<option value="0">江苏</option>
<option value="0">浙江</option>
<option value="0">海南</option>
<option value="0">福建</option>
<option value="0">山东</option>
<option value="0">青海</option>
<option value="0">宁夏</option>
<option value="0">内蒙古</option>
<option value="0">新疆</option>
<option value="0">陕西</option>
</select>
</td>
<td width="50" valign="middle">
<p style="width:100%" align="center"><input type="button" value="->" title="添加"></p>
<p style="width:100%" align="center"><input type="button" value="=>" title="添加全部"></p>
<p style="width:100%" align="center"><input type="button" value="<-" title="删除"></p>
<p style="width:100%" align="center"><input type="button" value="<=" title="删除全部"></p>
</td>
<td width="150">
<form id="frmDisplay" action="xxx.jsp" method="post" style="margin:0 ">
<select name="dltTarget" size="10" multiple style="width:100% "></select>
</form>
</td>
</tr>
<tr>
<td align="center">作者:梅雪香</td>
<td align="center">ver:1.0</td>
<td align="center">
<input type="reset" value="重置">
<input type="button" value="提交" >
</td>
</tr>
</table>
</body>
</html>