移动、交换SELECT内容

    技术2022-05-11  119

    <title>移动、交换SELECT内容</title> <style type="text/css"> <!-- body { background-color:#CECECE;} button { font-family:"webdings";font-size:10px;width:17px;height:15px;line-height:4px;} select { font-family:"Verdana";font-size:11px;} --> </style> <script>var createDate = "2003.8.23";</script> <script language="javascript" defer> //添加事件 fromSel.attachEvent("ondblclick",new Function("MoveOptions(fromSel,toSel)")) toSel.attachEvent("ondblclick",new Function("MoveOptions2(toSel,fromSel)")) LeftButton.attachEvent("onmouseup",new Function("MoveOptions(fromSel,toSel)")) RightButton.attachEvent("onmouseup",new Function("MoveOptions2(toSel,fromSel)")) //移动函数 function MoveOptions(oFrom,oTo) {  for (var i=1;i<oFrom.length;i++) {   if (oFrom.options[i].selected) {    oTo.options[oTo.length] = new Option(oFrom.options[i].text,oFrom.options[i].value);    //oFrom.options[i--] = null;    if (event.type=="dblclick") return;   }  } } function MoveOptions2(oFrom,oTo){  for (var i=1;i<oFrom.length;i++){   if (oFrom.options[i].selected){    //oFrom.options[oTo.length] = new option(oFrom.options[i].text,oFrom.options[i].value);    oFrom.options[i--] = null;    if (event.type=="dblclick") return;   }  } } //交换函数 function SwapOptions(obj,direction) {  var objIndex = obj.selectedIndex;  var swapIndex=direction=="up"?objIndex-1:objIndex+1;  if ((swapIndex==obj.length&&direction=="down")||(swapIndex==-1&&direction=="up")||obj.selectedIndex==0||swapIndex<=0) return;  obj.options[objIndex].swapNode(obj.options[swapIndex]); } </script> <body> <table width="165" border="0" cellspacing="0" cellpadding="0"> <tr><td>  <button οnmοuseup="SwapOptions(fromSel,'up')">5</button>  <button οnmοuseup="SwapOptions(fromSel,'down')">6</button> </td></tr> <tr><td>  <select id="fromSel" multiple size=10>   <option>---请选择要进入的网站---</option>   <option>CSND.net</option>   <option>MSND.com</option>   <option>Blueidea.com</option>   <option>51job.com</option>   <option>Yahoo.com</option>   <option>Pchome.net</option>   <option>Sina.com.cn</option>  </select> </td></tr> <tr><td align="center">  <button id="RightButton">7</button>  <button id="LeftButton">8</button> </td></tr> <tr><td>  <select id="toSel" multiple size=10>  <option>---请选择感兴趣的网站---</option>  </select> </td></tr> <tr><td align="right">  <button οnmοuseup="SwapOptions(toSel,'up')">5</button>  <button οnmοuseup="SwapOptions(toSel,'down')">6</button> </td></tr> </table> <SCRIPT LANGUAGE="JavaScript" SRC="createDate.js"></SCRIPT> <br> <SCRIPT LANGUAGE="JavaScript" SRC="list.js"></SCRIPT>

    最新回复(0)