打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
select multiple左右添加和删除功能
下拉列表
<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代码:
/**
  *动态的给左边的下拉列表创建选项
  *具体情况可以从数据库读取数据动态创建选项
  */
$(document).ready(function(){
        for(var i=1;i<=5;i++)
        {
               $("#fb_list").append("<option value='"+i+"'>公开招标小型机采购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("请选择要删除的分包!");
                      }
           })
})
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
关于jquery的多选框获取值和状态回显
wrap()
jquery获取框值的数据,收藏一下吧
博客个性自定义HTML模块代码大全
选项卡
样式可控的左右选择组件
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服