首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

Jquery 两个select多选控件中项的挪动的相关操作

2013-03-10 
Jquery 两个select多选控件中项的移动的相关操作htmlheadlink href${ctx}/css/style.css relsty

Jquery 两个select多选控件中项的移动的相关操作

<html><head>    <link href="${ctx}/css/style.css" rel="stylesheet"type="text/css" />    <script src="${ctx}/lib/jquery/jquery-1.5.2.min.js" type="text/javascript"></script><script type="text/javascript"> /**   *动态的给左边的下拉列表创建选项   *具体情况可以从数据库读取数据动态创建选项   */ $(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("请选择要删除的分包!");             }       })  }) //提交按扭获取左右的options所有值传给后台处理function sel(){ var obj = document.getElementById('fb_list');  var str="";          for(var i=0;i<obj.options.length;i++)     {         if(str.length>0)             str = str + "," + obj.options[i].value;         else             str = obj.options[i].value;     }          alert(str);}</script> </head><body><div class="searchDiv mcenter" style="width:400px;">  <form name="form1" method="post" id="form1">        <table style="width:395px;margin:10px 0;" align="center" class="tblresult">   <tr>   <th colspan="3" style="font-size:14px;text-align: center">添加人员</th>   </tr>   <tr>   <td>   <table class="noborder">   <tr>   <th>已有人员</th>   </tr>   <tr><td>    <select id="fb_list" name="seled" multiple="true" style="width:160px;height:200px;">     <option value="1">张三</option>    </select>    </td></tr>    </table>   </td>   <td>    <table class="noborder"><tr><td>    <input id="add" type="button" value=">>" style="width:30px;"/></td></tr>    <tr><td>    <input id="delete" type="button" value="<<" style="width:30px;"/>    </td></tr></table>   </td>   <td>   <table class="noborder">   <tr>   <th>备用人员</th>   </tr>   <tr><td>    <select id="select_list" name="unseled" multiple="true" style="width:160px;height:200px;">     <option value="4">李四</option>     <option value="5">王五</option>    </select>    </td></tr>    </table>   </td>   </tr>            <tr>                <td colspan="3" style="text-align:center;height:35px;">    <input type="button" value="保存" class="btn1" onclick="sel();"/>    <input type="button" value="取消" onclick="javascript:doClose();" class="btn1"/>    </td>            </tr>          </table>          </form> </div></body></html>


 

热点排行