網頁標籤(tab)效果

來源:互聯網
上載者:User

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>multiple select</TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<style type="text/css">
    input{margin:5px;width:30px;}
</style>

</HEAD>

<BODY>
    <div id="container" name="container" style="width:300px;text-align:center;">
        <div id="left_select" name="left_select" style="float:left;">
            <form id="left_form" name="left_form">
                <select id="l_select" name="l_select" multiple size=10 style="width:100px;height:200px;">
                    <option value="hunan">湖南</option>
                    <option value="hubei">湖北</option>
                    <option value="guangdong">廣東</option>
                    <option value="guangxi">廣西</option>
                    <option value="henan">河南</option>
                    <option value="hebei">河北</option>
                </select>
            </form>
        </div>

        <div id="right_select" name="right_select"  style="float:right;width:180px;">
            <span id="button" name="button" style="width:50px;float:left;text-align:left;line-height:30px;margin-left:15px;">
                <form >
                    <input type="button" value=">"  onclick="sigle_remove(document.forms[0].l_select,document.forms[2].r_select)"/><br>
                    <input type="button" value=">>" onclick="mul_remove(document.forms[0].l_select,document.forms[2].r_select)"/><br>
                    <input type="button" value="<"  onclick="sigle_remove(document.forms[2].r_select,document.forms[0].l_select)"/><br>
                    <input type="button" value="<<" onclick="mul_remove(document.forms[2].r_select,document.forms[0].l_select)"/><br>
                    <input type="button" value=">>>" onclick="all_remove(document.forms[0].l_select,document.forms[2].r_select)"/><br>
                    <input type="button" value="<<<" onclick="all_remove(document.forms[2].r_select,document.forms[0].l_select)"/>
                </form>
            </span>
            <form id="right_form" name="right_form" style="float:right;">
                <select id="r_select" name="r_select" multiple size=10 style="width:100px;height:200px;">
                   
                </select>
            </form>
        </div>

    </div>
<script type="text/javascript">
   
   
    var right = document.forms[2].r_select.options.length=0;
   
    //單個移動
    function sigle_remove(from,to){
       
        var index = from.selectedIndex;
        if( index==-1 ){

            alert("請選擇一項");

        }else{
           
            var value = from.options[index].value;
            var text = from.options[index].text;
            to.options[(to.length)] = new Option(text,value);
            from.options[index]=null;
        }
       
    }
   
    //多個移動
    function mul_remove(from,to){
       
        var text ;
        var value ;
        var length = from.length;
        var tempArray = new Array();
        if( from.selectedIndex==-1 ){
            alert("至少選擇一項");
        }else{
            for( var i = 0 ; i<length;i++){
               
                if(from.options[i].selected){
                    value = from.options[i].value;
                    text = from.options[i].text;
                    to.options[to.length] = new Option(text,value);
                }else{
                    value = from.options[i].value;
                    text = from.options[i].text;
                    tempArray[tempArray.length]= new Option(text,value);
                }
            }

            from.options.length=0;
            for(var j = 0 ; j<tempArray.length;j++ ){
               
                from.options[from.options.length] = tempArray[j];
            }
        }
    }

    //全部移動
    function all_remove(from,to){

        var index = from.selectedIndex;
        var value ;
        var length = from.length;
        //alert(length);
        var text ;
        for( var i = 0 ; i< length;i++){
               
                value = from.options[i].value;
                text = from.options[i].text;
                to.options[to.length] = new Option(text,value);
           
        }

        for( var i = length-1 ; i>=0;i--){

            from.options[i]=null;
           
        }
    }
</script>

</BODY>
</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.