<div class="select-bar">
<select multiple="multiple" id="select1" name="evalId1">
<c:forEach items="${evalList }" var="ev">
<option value="${ev.eval_id }">${ev.eval_type}</option>
</c:forEach>
</select>
</div>
<div class="btn-bar">
<span id="add_evalId"><input type="button" class="btn" value=">"/></span><br />
<span id="add_all_evalId"><input type="button" class="btn" value=">>"/></span><br />
<span id="remove_evalId"><input type="button" class="btn" value="<"/></span><br />
<span id="remove_all_evalId"><input type="button" class="btn" value="<<"/></span>
</div>
<div class="select-bar">
<select multiple="multiple" id="select2"></select>
</div>
//移到右边
$('#add_evalId').click(function(){
//获取选中的选项,删除并追加给对方
$('#select1 option:selected').appendTo('#select2');
});
//移到左边
$('#remove_evalId').click(function(){
$('#select2 option:selected').appendTo('#select1');
});
//全部移到右边
$('#add_all_evalId').click(function(){
//获取全部的选项,删除并追加给对方
$('#select1 option').appendTo('#select2');
});
//全部移到左边
$('#remove_all_evalId').click(function(){
$('#select2 option').appendTo('#select1');
});
//双击选项
$('#select1').dblclick(function(){ //绑定双击事件
//获取全部的选项,删除并追加给对方
$("option:selected",this).appendTo('#select2'); //追加给对方
});
//双击选项
$('#select2').dblclick(function(){
$("option:selected",this).appendTo('#select1');
});
//获取select选择的值
var evalIds="";
var obj = document.getElementById('select2');
var options = obj.options;
for(var i=0,len=options.length;i<len;i++){
var opt = options[i];
evalIds+=opt.value+",";
}
select 多选的方法
最新推荐文章于 2024-06-11 16:39:30 发布