jojo's blog--快乐忧伤都与你同在
为梦想而来,为自由而生。 性情若水,风起水兴,风息水止,故时而激荡,时又清平……
posts - 11,  comments - 30,  trackbacks - 0
<html> 
    
<head> 
        
<title>js list table</title> 
    
</head> 
 
    
<script language="javascript"> 
    
<!--  
    var ListUtil 
= new Object();  

    
//MOVE ALL
    ListUtil.moveAll = function moveAll(oListboxFrom,oListboxTo){  
        var options 
= oListboxFrom.options;  
        
for(var i = 0; i < options.length; i++){  
            oListboxTo.appendChild(options[i]); 
//???  
            i -= 1;
        }
    }  

    
//MOVE sigle 
    ListUtil.moveMuti = function moveMuti(oListboxFrom,oListboxTo){
        var options 
= oListboxFrom.options;  
        
for(var i = 0; i < options.length; i++){
            
if(options[i].selected){
                oListboxTo.appendChild(options[i]);
                i 
-= 1;
            }
        }
    }  

    
//MOVE UP
    ListUtil.shiftUp = function(oListbox) {
        
if(oListbox.selectedIndex > 0){
            var oOption 
= oListbox.options[oListbox.selectedIndex];
            var oPrevOption 
= oListbox.options[oListbox.selectedIndex-1];
            oListbox.insertBefore(oOption,oPrevOption);
        }
    }  

    
//MOVE DOWN
    ListUtil.shiftDown = function(oListbox){
        
if(oListbox.selectedIndex < oListbox.options.length-1){
            var oOption 
= oListbox.options[oListbox.selectedIndex];
            var oNextOption 
= oListbox.options[oListbox.selectedIndex+1];
            oListbox.insertBefore(oNextOption,oOption);
        }
    }  

    
//--> 
    </script> 

    
<body text="#000000" bgcolor="#ffffff" link="#0033cc"> 
    
<form method=post action="#"> 
    
<table>
        
<tr>
            
<td>
                Unselected employee
                
<select name="oListboxFrom" id="oListboxFrom" size="10" multiple="true" 
                    style
="width:100px;height:250px;margin-left:20px;float:left"> 
                    
<option value="1" selected>tim</option> 
                    
<option value="2">jojo</option>
                    
<option value="3">simon</option>
                    
<option value="4">ata</option>
                    
<option value="5">jimy</option>
                
</select>
            
</td> 

            
<td align="center">
                
<input type="button" value=" >>> "
                    onclick
="ListUtil.moveAll(oListboxFrom, oListboxTo);" />
                
<br/> 

                
<input type="button" value=" >> "
                    onclick
="ListUtil.moveMuti(oListboxFrom, oListboxTo);" />
                
<br/> 

                
<input type="button" value=" << "
                    onclick
="ListUtil.moveMuti(oListboxTo, oListboxFrom);" />
                
<br/> 

                
<input type="button" value=" <<< "
                    onclick
="ListUtil.moveAll(oListboxTo, oListboxFrom);" />
                
<br/> 

                
<input type="button" value="MovePrev " 
                    onclick
="ListUtil.shiftUp(oListboxFrom);" />
                
<br/> 

                
<input type="button" value="MoveNext" 
                    onclick
="ListUtil.shiftDown(oListboxFrom);" />
            
</td> 

            
<td>
                Selected Employees
                
<select name="oListboxTo" id="oListboxTo" multiple="true" size="10" 
                    style
="width:100px;height:250px;margin-left:20px;float:left">
                    
<option value="319094784">cindy</option>
                    
<option value="320274432">nancy</option>
                    
<option value="322109440">amy</option>
                
</select>
            
</td>
        
</tr> 
    
</table> 
    
</form>
    
</body> 

</html>

效果:
Unselected employee




Selected Employees

posted on 2008-10-09 18:39 Blog of JoJo 阅读(111) 评论(0)  编辑  收藏 所属分类: Linux 技术相关

只有注册用户登录后才能发表评论。


网站导航:
 

<2024年12月>
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

常用链接

留言簿(6)

随笔档案

文章分类

文章档案

新闻分类

新闻档案

相册

收藏夹

搜索

  •  

最新评论

阅读排行榜

评论排行榜