---------------------------------------------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>start</title>
<LINK rel="stylesheet" href="../../css/main.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>
<body MS_POSITIONING="GridLayout">
<FONT face="宋体"></FONT><FONT face="宋体"></FONT><FONT face="宋体"></FONT>
<BR>
<table width="200" border="0" align="center">
<tr>
<td class="Title" align="center" nowrap>
手工排序
</td>
</tr>
</table>
<BR>
<form id="Form1" method="post" action="do.asp">
<table align="center">
<tr align=center>
<td width=160><select size=10 name="list1" style="width:120">
<option value=1>1111111</option>
<option value=2>2222222</option>
<option value=3>3333333</option>
<option value=4>4444444</option>
<option value=5>5555555</option>
<option value=6>6666666</option>
<option value=7>7777777</option>
</select></td>
<td><input type="button" value="增 加>>>" onclick="add()">
<br/>
<br/>
<input type="button" value="<<<删 除" onclick="del()">
</td>
<td width=79><select name="seqItem" id="seqItem" size="10" style="width:120">
</select></td>
<td width=79><p align="center">
<input type="button" value="移动到顶部" onClick="doTopItem()">
</p>
<p align="center">
<input type="button" name="Submit" value="向上移动" onClick="doUpItem()">
</p>
<p align="center">
<input type="button" name="Submit" value="向下移动" onClick="doDownItem()" >
</p>
<p align="center">
<input type="button" name="Submit" value="移动到底部" onClick="doBottomItem()">
</p></td>
</tr>
</table>
<div align="center">
<input type="button" value="测 试" onClick="goClick()">
<input type="button" value="重 置" onClick="doRe()">
<input type="submit" name="ok" value="提 交">
</div>
</form>
<SCRIPT LANGUAGE="
java script">
var seqSelect=document.forms[0].seqItem;
var length=5;
//go top
function doTopItem(){
var length=seqSelect.options.length;
var topV,topT;
var tempV=new Array();
var tempT=new Array();
for(var i=0;i<length;i++){
if(seqSelect.options[i].selected){
if(i==0)
return false;
topV=seqSelect.options[0].value;
topT=seqSelect.options[0].text;
seqSelect.options[0].value=seqSelect.options[i].value;
seqSelect.options[0].text=seqSelect.options[i].text;
for(var j=1;j<length;j++){
tempV[j]=seqSelect.options[j].value;
tempT[j]=seqSelect.options[j].text;
alert(tempV+" ··· "+tempT);
if(j==1){
seqSelect.options[1].value=topV;
seqSelect.options[1].text=topT;
}
else if(j>i){
break;
}
else{
seqSelect.options[j].value=tempV[j-1];
seqSelect.options[j].text=tempT[j-1];
}
}
}
}
seqSelect.options[0].selected=true;
}
//go bottom
function doBottomItem(){
var length=seqSelect.options.length;
var bottomV,bottomT;
var tempV=new Array();
var tempT=new Array();
for(var i=0;i<length;i++){
if(seqSelect.options[i].selected){
if(i==(length-1))
return false;
bottomV=seqSelect.options[length-1].value;
bottomT=seqSelect.options[length-1].text;
seqSelect.options[length-1].value=seqSelect.options[i].value;
seqSelect.options[length-1].text=seqSelect.options[i].text;
for(var j=length-2;j>=0;j--){
tempV[j]=seqSelect.options[j].value;
tempT[j]=seqSelect.options[j].text;
alert(tempV+" ··· "+tempT);
if(j==(length-2)){
seqSelect.options[length-2].value=bottomV;
seqSelect.options[length-2].text=bottomT;
}
else if(j<i){
break;
}
else{
seqSelect.options[j].value=tempV[j+1];
seqSelect.options[j].text=tempT[j+1];
}
}
}
}
seqSelect.options[length-1].selected=true;
}
//go up 1
function doUpItem(){
var length=seqSelect.options.length;
var tempV,tempT;
for(var i=0;i<length;i++){
if(seqSelect.options[i].selected){
if(i==0)
return false;
tempV=seqSelect.options[i-1].value;
tempT=seqSelect.options[i-1].text;
seqSelect.options[i-1].value=seqSelect.options[i].value;
seqSelect.options[i-1].text=seqSelect.options[i].text;
seqSelect.options[i].value=tempV;
seqSelect.options[i].text=tempT;
seqSelect.options[i-1].selected=true;
break;
}
}
}
//go down 1
function doDownItem(){
var length=seqSelect.options.length;
var tempV,tempT;
for(var i=0;i<length;i++){
if(seqSelect.options[i].selected){
if(i==(length-1))
return false;
tempV=seqSelect.options[i+1].value;
tempT=seqSelect.options[i+1].text;
seqSelect.options[i+1].value=seqSelect.options[i].value;
seqSelect.options[i+1].text=seqSelect.options[i].text;
seqSelect.options[i].value=tempV;
seqSelect.options[i].text=tempT;
seqSelect.options[i+1].selected=true;
break;
}
}
}
原文转自:http://www.ltesting.net