日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

select multiple左右添加和刪除功能

 WindySky 2009-06-24
下拉列表
<table width="95%" cellpadding="0" align="center" class="listshow" border="1" cellspacing="0">
<tr>
     <td colspan="4" align="center">選擇分包</td>
    </tr>
<tr>
  <td class="black" width="30%" align="center" height="150">
              <select id="fb_list" multiple="multiple"  style="text-align:center;width:300px;height:150px;">
             
               </select> 
        </td>
        <td align="center" width="5%">
         <input type="button" id="add" value="添加>>" />
            <br/>
            <br/>
            <input type="button" id="delete" value="<<刪除" />
        </td>
        <td class="black" width="30%" align="center">
         <select id="select_list" multiple="multiple" style=" text-align:center;width:300px;height:150px;">
                     
            </select>
        </td>
</tr>
</table>

jQuery代碼:
/**
  *動態(tài)的給左邊的下拉列表創(chuàng)建選項
  *具體情況可以從數(shù)據(jù)庫讀取數(shù)據(jù)動態(tài)創(chuàng)建選項
  */
$(document).ready(function(){
        for(var i=1;i<=5;i++)
        {
               $("#fb_list").append("<option value='"+i+"'>公開招標(biāo)小型機采購00"+i+"</option>"); 
        }
})

$(function(){
     $("#add").click(function(){
              if($("#fb_list option:selected").length>0)
              {
                       $("#fb_list option:selected").each(function(){
                            $("#select_list").append("<option value='"+$(this).val()+"'>"+$(this).text()+"</option");
                            $(this).remove(); 
                       })
              }
              else
              {
                       alert("請選擇要添加的分包!");
              }
       })
})


$(function(){
             $("#delete").click(function(){
                      if($("#select_list option:selected").length>0)
                      {
                               $("#select_list option:selected").each(function(){
                                          $("#fb_list").append("<option value='"+$(this).val()+"'>"+$(this).text()+"</option");
                                           $(this).remove(); 
                               })
                      }
                      else
                      {
                               alert("請選擇要刪除的分包!");
                      }
           })
})

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多