标题归移功能

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>MyHtml.html</title>
 
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
   
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
 <script type="text/javascript"><!--
  function moveSelectedItem(sourceId,destId){
   var source = document.getElementById(sourceId);
   var dest = document.getElementById(destId);
   if( source.selectedIndex < 0 ){
    return;
   }
   var selectedOption = source.options[source.selectedIndex];
   var newOption = document.createElement("OPTION");
   newOption.value = selectedOption.value;
   newOption.innerHTML=selectedOption.innerHTML;
   dest.insertBefore(newOption);
   source.removeChild(selectedOption);
  }
  
  function moveUp(sourceId){
   var source = document.getElementById(sourceId);
   if( source.selectedIndex < 1 ) {
    return;
   }
   
   var sIndex = source.selectedIndex;
   var ops = [];
   
   var op = source.options[sIndex];
   var op2 =source.options[sIndex - 1];
   var ll = source.options.length;
   for( var i = 0 ; i < ll ; i ++ ){
    ops[i] = source.options[0];
    source.removeChild(source.options[0]);
   }
   for( var i = 0 ; i < ll ; i ++ ){
    if( ops[i] == op ) {
     source.insertBefore(op);
     source.insertBefore(op2);
    } else if( ops[i] == op2 ){
     
    } else {
     source.insertBefore(ops[i]);
    }
   }
   
  }
  
  function moveDown(sourceId){
  var source = document.getElementById(sourceId);
   if( source.selectedIndex < 0 || source.selectedIndex >= source.options.length-1 ) {
    return;
   }
   
   var sIndex = source.selectedIndex;
   var ops = [];
   
   var op = source.options[sIndex];
   var op2 =source.options[sIndex + 1];
   var ll = source.options.length;
   for( var i = 0 ; i < ll ; i ++ ){
    ops[i] = source.options[0];
    source.removeChild(source.options[0]);
   }
   for( var i = 0 ; i < ll ; i ++ ){
    if( ops[i] == op ) {
     source.insertBefore(op2);
     source.insertBefore(op);
    } else if( ops[i] == op2 ){
     
    } else {
     source.insertBefore(ops[i]);
    }
   }
   
  }
  
  function showSelectValues(){
   var s1 = "";
   var t = document.getElementById('select1').options;
   for( var i = 0 ; i < t.length ; i ++ ){
    var o = t[i];
    s1 += o.value + ",";
   }
   alert(s1);
   
   s1 = "";
   t = document.getElementById('select2').options;
   for( var i = 0 ; i < t.length ; i ++ ){
    var o = t[i];
    s1 += o.value + ",";
   }
   alert(s1);
   
   s1 = "";
   t = document.getElementById('select3').options;
   for( var i = 0 ; i < t.length ; i ++ ){
    var o = t[i];
    s1 += o.value + ",";
   }
   alert(s1);
   return false;
  }
 --></script>
  </head>
 
  <body>
  <form οnsubmit="showSelectValues();">
  <table>
   <tr><td>
 <select id="select1" multiple="multiple" size="8">
  <option value="x" id="o1">xxxxx</option>
  <option value="y">yyyyy</option>
  <option value="z">zzzzz</option>
 </select>
 </td><td>
 <table>
  <tr><td><button οnclick="moveUp('select1');">&nbsp;&nbsp;&nbsp;&nbsp;^.&nbsp;&nbsp;&nbsp;&nbsp;</button></td></tr>
  <tr><td><button οnclick="moveDown('select1');">&nbsp;&nbsp;&nbsp;&nbsp;v.&nbsp;&nbsp;&nbsp;&nbsp;</button></td></tr>
  <tr><td><button οnclick="moveSelectedItem('select1','select2');">&nbsp;&nbsp;&nbsp;&nbsp;-&gt;&nbsp;&nbsp;&nbsp;&nbsp;</button></td></tr>
  <tr><td><button οnclick="moveSelectedItem('select2','select1');">&nbsp;&nbsp;&nbsp;&nbsp;&lt;-&nbsp;&nbsp;&nbsp;&nbsp;</button></td></tr>
 </table>
 </td><td>
 <select id="select2" multiple="multiple" size="8" >
  <option value="a">aaaaa</option>
  <option value="b">bbbbb</option>
  <option value="c">ccccc</option>
 </select>
 </td><td>
 <table>
  <tr><td><button οnclick="moveUp('select2');">&nbsp;&nbsp;&nbsp;&nbsp;^.&nbsp;&nbsp;&nbsp;&nbsp;</button></td></tr>
  <tr><td><button οnclick="moveDown('select2');">&nbsp;&nbsp;&nbsp;&nbsp;v.&nbsp;&nbsp;&nbsp;&nbsp;</button></td></tr>
  <tr><td><button οnclick="moveSelectedItem('select2','select3');">&nbsp;&nbsp;&nbsp;&nbsp;-&gt;&nbsp;&nbsp;&nbsp;&nbsp;</button></td></tr>
  <tr><td><button οnclick="moveSelectedItem('select3','select2');">&nbsp;&nbsp;&nbsp;&nbsp;&lt;-&nbsp;&nbsp;&nbsp;&nbsp;</button></td></tr>
 </table>
 </td><td>
 <select id="select3" multiple="multiple" size="8">
  <option value="m">mmmmm</option>
  <option value="n">nnnnn</option>
  <option value="u">uuuuu</option>
 </select>
 </td><td><table>
  <tr><td><button οnclick="moveUp('select3');">&nbsp;&nbsp;&nbsp;&nbsp;^.&nbsp;&nbsp;&nbsp;&nbsp;</button></td></tr>
  <tr><td><button οnclick="moveDown('select3');">&nbsp;&nbsp;&nbsp;&nbsp;v.&nbsp;&nbsp;&nbsp;&nbsp;</button></td></tr>
 </table></td></tr>
 </table>
 <input type="submit">
 </form>
  </body>
</html>

 

 


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值