不知道是不是这个意思
<html>
<head>
<title>Select Op</title>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312" />
<script type="text/javascript">
var o;
function MoveTo(index)
{
if (index!=undefined)
{
o=source.options[index];
distinct.options.add(new Option(o.text,o.value));
source.remove(index);
}
else
{
for(var i=0;i<source.options.length;)//不要在这里控制i的增长,因为有可能删除了option
{
if(source.options[i].selected)
{
o=source.options[i];
distinct.options.add(new Option(o.text,o.value));
source.remove(i);
i=0;
}
else
i++;
}
}
}
function MoveBack(index)
{
if (index!=undefined)
{
o=distinct.options[index];
source.options.add(new Option(o.text,o.value));
distinct.remove(index);
}
else
{
for(var i=0;i<distinct.options.length;)//不要在这里控制i的增长,因为有可能删除了option
{
if(distinct.options[i].selected)
{
o=distinct.options[i];
source.options.add(new Option(o.text,o.value));
distinct.remove(i);
i=0;
}
else
i++;
}
}
}
</script>
</head>
<body>
<table width='500' border='1' cellpadding='0' cellspacing='0'>
<tr>
<td width='45%' align="center"><select id='source' multiple="multiple" style="width:200; height:300" ondblclick="MoveTo(this.selectedIndex)">
<option value='1'>Item1</option>
<option value='2'>Item2</option>
<option value='3'>Item3</option>
<option value='4'>Item4</option>
<option value='5'>Item5</option>
<option value='6'>Item6</option>
</select></td>
<td width='10%' align="center"><input type="button" value=">>" onclick="MoveTo()" /><br /><input type="button" value="<<" onclick="MoveBack()" /></td>
<td width='45%'><select id='distinct' ondblclick="MoveBack(this.selectedIndex)" style="width:200; height:300" multiple="multiple" align="center"></select></td>
</tr>
</table>
</body>
</html>
<html>
<head>
<title>Select Op</title>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312" />
<script type="text/javascript">
var o;
function MoveTo(index)
{
if (index!=undefined)
{
o=source.options[index];
distinct.options.add(new Option(o.text,o.value));
source.remove(index);
}
else
{
for(var i=0;i<source.options.length;)//不要在这里控制i的增长,因为有可能删除了option
{
if(source.options[i].selected)
{
o=source.options[i];
distinct.options.add(new Option(o.text,o.value));
source.remove(i);
i=0;
}
else
i++;
}
}
}
function MoveBack(index)
{
if (index!=undefined)
{
o=distinct.options[index];
source.options.add(new Option(o.text,o.value));
distinct.remove(index);
}
else
{
for(var i=0;i<distinct.options.length;)//不要在这里控制i的增长,因为有可能删除了option
{
if(distinct.options[i].selected)
{
o=distinct.options[i];
source.options.add(new Option(o.text,o.value));
distinct.remove(i);
i=0;
}
else
i++;
}
}
}
</script>
</head>
<body>
<table width='500' border='1' cellpadding='0' cellspacing='0'>
<tr>
<td width='45%' align="center"><select id='source' multiple="multiple" style="width:200; height:300" ondblclick="MoveTo(this.selectedIndex)">
<option value='1'>Item1</option>
<option value='2'>Item2</option>
<option value='3'>Item3</option>
<option value='4'>Item4</option>
<option value='5'>Item5</option>
<option value='6'>Item6</option>
</select></td>
<td width='10%' align="center"><input type="button" value=">>" onclick="MoveTo()" /><br /><input type="button" value="<<" onclick="MoveBack()" /></td>
<td width='45%'><select id='distinct' ondblclick="MoveBack(this.selectedIndex)" style="width:200; height:300" multiple="multiple" align="center"></select></td>
</tr>
</table>
</body>
</html>
解决方案 »
- 怎么才能让$.getScript只在没有载入过这个js文件的情况下加载JS?
- 眼睛看花了 试了无数遍找不出问题所在()兼容问题(IE6下不正常)
- 求一个在浏览器上非常平滑的跑马灯(滚动文字)的 js
- 急!急!!! xmlDom在javascript中如何保存xml文件
- 为什么第二个form没有elements对象?
- $.fn.extend() 和 $.extend() 的区别
- 同志們幫我看看什麼回事?非常的急呀
- 什么命令可以 在某元素里,直接使得另外一个元素里的事件发生?
- 再问关于javascript计算的问题!
- window.print()方法调用时如何可以不要出现打印对话框,让其按照默认的方式打印
- 火星人的耳机 - 趣谈web开发标准
- 如何使日期增加1个月?
if (index!=undefined)
{
if(index<0)return;//这加个判断吧,没选双击的话有异常
o=source.options[index];
distinct.options.add(new Option(o.text,o.value));
source.remove(index);
}