列表项可上下移动的Multiple列表

2018-09-06 11:03

阅读:506

  <HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME=Generator CONTENT=EditPlus>
<META NAME=Author CONTENT=>
<META NAME=Keywords CONTENT=>
<META NAME=Description CONTENT=>
<STYLE>
BODY, SELECT
{
FONT-FAMILY: TIMES NEW ROMAN;
FONT-SIZE: 10PT;
}
</STYLE>
<SCRIPT LANGUAGE=JavaScript>
<!--
window.onload = initPage;
function initPage()
{
btnPutUp.onclick= putUp;
btnPutDown.onclick= putDown;

btnGoUp.onclick= goUp;
btnGoDown.onclick= goDown;
}

function putUp()
{
var strTempValue;
var strTempText;
var intCurIndex;

intCurIndex = sltFruit.selectedIndex;
//alert(intCurIndex: + intCurIndex);

if (intCurIndex > 0)
{
strTempValue= sltFruit.options.item(intCurIndex).value;
strTempText= sltFruit.options.item(intCurIndex).text;
//alert(strTempText + - + strTempValue);

sltFruit.options.item(intCurIndex).value= sltFruit.options.item(intCurIndex - 1).value;
sltFruit.options.item(intCurIndex).text= sltFruit.options.item(intCurIndex - 1).text;
sltFruit.options.item(intCurIndex - 1).value= strTempValue;
sltFruit.options.item(intCurIndex - 1).text= strTempText;
sltFruit.selectedIndex = intCurIndex - 1;
}
}

function putDown()
{
var strTempValue;
var strTempText;
var intCurIndex;
var intIndexCount;

intCurIndex= sltFruit.selectedIndex;
intIndexCount= sltFruit.length;
//alert(intCurIndex: + intCurIndex);
//alert(intIndexCount: + intIndexCount);

if (intCurIndex < intIndexCount - 1)
{
strTempValue= sltFruit.options.item(intCurIndex).value;
strTempText= sltFruit.options.item(intCurIndex).text;
//alert(strTempText + - + strTempValue);


评论


亲,登录后才可以留言!