清單項目可上下移動的Multiple列表

來源:互聯網
上載者:User
<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);
        
        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 goUp()
{
    var intCurIndex;
    intCurIndex = sltCountry.selectedIndex;

    if (intCurIndex > 0)
        sltCountry.selectedIndex = intCurIndex - 1;
}

function goDown()
{
    var intCurIndex;
    var intIndexCount;
    
    intCurIndex        = sltCountry.selectedIndex;
    intIndexCount    = sltCountry.length;
    
    if (intCurIndex < intIndexCount - 1)
        sltCountry.selectedIndex = intCurIndex + 1;
}
//-->
</SCRIPT>
</HEAD>

<BODY>

</BODY>
水果列表<BR>
1 - 香蕉<BR>
2 - 蘋果<BR>
3 - 葡萄<BR>
4 - 桔子<BR>
5 - 西瓜<BR>
<SELECT NAME="sltFruit" SIZE="5">
    <OPTION VALUE="1">香蕉</OPTION>
    <OPTION VALUE="2">蘋果</OPTION>
    <OPTION VALUE="3">葡萄</OPTION>
    <OPTION VALUE="4">桔子</OPTION>
    <OPTION VALUE="5">西瓜</OPTION>
</SELECT>

<INPUT TYPE="BUTTON" ID="btnPutUp" VALUE="上移">
<INPUT TYPE="BUTTON" ID="btnPutDown" VALUE="下移">
<HR>

國家列表<BR>
1 - China<BR>
2 - USA<BR>
3 - USSR<BR>
4 - England<BR>
5 - France<BR>
<SELECT NAME="sltCountry">
    <OPTION VALUE="1">China</OPTION>
    <OPTION VALUE="2">USA</OPTION>
    <OPTION VALUE="3">USSR</OPTION>
    <OPTION VALUE="4">England</OPTION>
    <OPTION VALUE="5">France</OPTION>
</SELECT>

<INPUT TYPE="BUTTON" ID="btnGoUp" VALUE="上移">
<INPUT TYPE="BUTTON" ID="btnGoDown" VALUE="下移">
</HTML>



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.