javascript实现在左边List列表选取后在右边List列表显示 !急用!帮帮忙!
解决方案 »
- 这种功能怎么实现啊,求教
- iframe 里面方法
- 请教---JS截取字符串---谢谢大家
- 有用jatoolsPrinter的吗,有问题请教!
- 为什么的我机器不能运行vbscript,但可以运行javascript
- 请问各位大侠,请问关于javascript控制窗口问题,急...
- 动态插入删除表格,HELP
- 网页A重定向到网页B,如何在网页B中知道网页A的地址?
- 用JAVASCRIPT写出当在浏览器任意一个地方按鼠标左键时显示“这个文档被点击了”。
- 在SCRIPT中如何调用按钮中的ONCLICK事件
- 有甚麽感觉?
- javascript实现在左边List列表选取后在右边List列表显示!急用!帮帮忙!!!!
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>JK:支持民族工业,尽量少买X货</title>
</head>
<body >
<div style="font-size:10pt;">
注1:左右移动进行选取 <br/> <br/>
注:本页面仅在IE6/FireFox1.5下测试过。其它浏览器或其它版本未经测试。<br/>
注-----:作者JK:<a href="mailTo:[email protected]?subject=About%20MoveRightOrLeft">[email protected]</a><br/>
<hr/>
</div><form name=frm><table>
<tr >
<td>
<select name=SrcSelect size=6 style="font-size:11pt;width:200px;height:160px" multiple ondblclick="moveLeftOrRight(document.frm.SrcSelect,document.frm.ObjSelect)">
<option value="1">test1</option>
<option value="2">test2</option>
<option value="3">test3</option>
<option value="4">test4</option>
<option value="5">test5</option>
<option value="6">test6</option>
<option value="7">test7</option>
<option value="8">test8</option>
<option value="9">test9</option>
</select>
</td>
<td width="30px">
<input align="left" type=button value=">" onclick="moveLeftOrRight(document.frm.SrcSelect,document.frm.ObjSelect)" ><br><br>
<input align="left" type=button value="<" onclick="moveLeftOrRight(document.frm.ObjSelect,document.frm.SrcSelect)" >
</td>
<td>
<select name=ObjSelect size=6 style="font-size:11pt;width:200px;height:160px" multiple ondblclick="moveLeftOrRight(document.frm.ObjSelect,document.frm.SrcSelect)">
<option value="11">test11</option>
<option value="12">test12</option>
<option value="13">test13</option>
<option value="14">test14</option>
<option value="15">test15</option>
<option value="16">test16</option>
</select>
</td>
<td width="30px">
<input type=button value="A" onclick="moveUp()" > <br><br>
<input type=button value="V" onclick="moveDown()" >
</td>
</tr>
</table></form>
</body>
<script language=javascript>
function moveUp()
{
var theObjOptions=document.frm.ObjSelect.options;
for(var i=1;i<theObjOptions.length;i++)
{
if( theObjOptions[i].selected && !theObjOptions[i-1].selected )
{
swapOptionProperties(theObjOptions[i],theObjOptions[i-1]);
}
}
}
function moveDown()
{
var theObjOptions=document.frm.ObjSelect.options;
for(var i=theObjOptions.length-2;i>-1;i--)
{
if( theObjOptions[i].selected && !theObjOptions[i+1].selected )
{
swapOptionProperties(theObjOptions[i],theObjOptions[i+1]);
}
}
} function swapOptionProperties(option1,option2){
var tempStr=option1.value;
option1.value=option2.value;
option1.value=tempStr;
tempStr=option1.text;
option1.text=option2.text;
option2.text=tempStr;
tempStr=option1.selected;
option1.selected=option2.selected;
option2.selected=tempStr;
}
function moveLeftOrRight(fromObj,toObj)
{
for(var i=0;i<fromObj.length;i++)
{
var srcOption=fromObj.options[i];
if(srcOption.selected)
{
toObj.appendChild(srcOption);
i--;
}
}
}
</script>