欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2023-08-29 16:57:16
new document
<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);