Dynamic Select Item left to right


 

 

1)Jsp 

<th class="span5">

   <div class="text-center">

       <s:select id="document" name="documentCodes" multiple="true" cssStyle="width:400px;" size="22"                     list="masterPolicyDocumentsManagementTabDto.documentList" listKey="code"                                         listValue="i18nLabel"/>

   </div>

</th>      

 

<th class="span2">

                    <div class="text-center">

                        <button class="btn" type="button" id="addAll"> &nbsp;&gt;&gt;&nbsp; </button>

                            <br/> 

                        <button class="btn" type="button" id="add"> &nbsp;&nbsp;&gt;&nbsp;&nbsp; </button>

                            <br/> 

                        <button class="btn" type="button" id="remove"> &nbsp;&nbsp;&lt;&nbsp;&nbsp; </button>

                            <br/> 

                        <button class="btn" type="button" id="removeAll"> &nbsp;&lt;&lt;&nbsp; </button>

                    </div>

</th>

<th class="span5">

   <div class="text-center">

         <s:select id="documentClaim" name="documentClaimDocumentCodes" multiple="true"                                     cssStyle="width:400px;" size="22"                                                                                                                 list="masterPolicyDocumentsManagementTabDto.documentClaimList"                                                       listKey="documentCode" listValue="documentDto.i18nLabel"/>

   </div>

</th>

 

2)Jquery

       $("#addAll").click(function(){ 

        if($("#document option").length>0){ 

            $("#document option").each(function(){ 

                 $("#documentClaim").append("<option value='"+$(this).val()+"'>"+$(this).text()+"</option"); 

                 $(this).remove();

            })

        }

    }) 

 

    $("#add").click(function(){ 

        if($("#document option:selected").length>0){ 

            $("#document option:selected").each(function(){ 

                 $("#documentClaim").append("<option value='"+$(this).val()+"'>"+$(this).text()+"</option"); 

                 $(this).remove();  

            })

        }else{

            addAlert('<s:text name="rsc.alert.msg.availableDocumentsMandatory" />');

        }

    }) 

          

    $("#remove").click(function(){

        if($("#documentClaim option:selected").length>0) { 

            $("#documentClaim option:selected").each(function(){ 

                $("#document").append("<option value='"+$(this).val()+"'>"+$(this).text()+"</option"); 

                $(this).remove();  

            })

        }else{

            addAlert('<s:text name="rsc.alert.msg.claimDocumentsMandatory" />');

        }

    })

 

    $("#removeAll").click(function(){

        if($("#documentClaim option").length>0) { 

            $("#documentClaim option").each(function(){ 

                $("#document").append("<option value='"+$(this).val()+"'>"+$(this).text()+"</option"); 

                $(this).remove();  

            })

        }

    })

 

//remove linked docs

function removeLinkedDocuments(){

    var doclaim = new Array();

    var i = 0;

    if($("#documentClaim option").length>0) { 

        $("#documentClaim option").each(function(){ 

            doclaim[i] = $(this).val();

            i++;

        })

    }

 

    if($("#document option").length>0) { 

        $("#document option").each(function(){ 

            for(var j = 0; j < doclaim.length; j++){

                if($(this).val() == doclaim[j]){

                    $(this).remove();

                    break;

                }

            }

        })

    }

}

 

 



 参考地址:http://blog.csdn.net/netzmj/article/details/12008253

 

 



 

 

参考地址:http://www.thinksaas.cn/group/topic/229013/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值