这是我完全需要的图像。请通过图像。
问问题
5599 次
4 回答
2
希望这会对你有所帮助
-JSFIDDLE
<script language="Javascript">
function SelectMoveRows(SS1,SS2)
{
var SelID='';
var SelText='';
// Move rows from SS1 to SS2 from bottom to top
for (i=SS1.options.length - 1; i>=0; i--)
{
if (SS1.options[i].selected == true)
{
SelID=SS1.options[i].value;
SelText=SS1.options[i].text;
var newRow = new Option(SelText,SelID);
SS2.options[SS2.length]=newRow;
SS1.options[i]=null;
}
}
SelectSort(SS2);
}
function SelectSort(SelList)
{
var ID='';
var Text='';
for (x=0; x < SelList.length - 1; x++)
{
for (y=x + 1; y < SelList.length; y++)
{
if (SelList[x].text > SelList[y].text)
{
// Swap rows
ID=SelList[x].value;
Text=SelList[x].text;
SelList[x].value=SelList[y].value;
SelList[x].text=SelList[y].text;
SelList[y].value=ID;
SelList[y].text=Text;
}
}
}
}
function selectAll(Sels){
for (x=0; x < Sels.length ; x++){
Sels[x].selected = "1";
}
}
</script>
<form name="Example">
<table border="0" cellpadding="3" cellspacing="0">
<tr>
<td>
<select name="Features" size="9" MULTIPLE>
<option value="2">Row 2</option>
<option value="4">Row 4</option>
<option value="5">Row 5</option>
<option value="6">Row 6</option>
<option value="7">Row 7</option>
<option value="8">Row 8</option>
<option value="9">Row 9</option>
</select>
</td>
<td align="center" valign="middle">
<input type="Button" value="Add >>" style="width:100px" onClick="SelectMoveRows(document.Example.Features,document.Example.FeatureCodes)"><br>
<br>
<input type="Button" value="<< Remove" style="width:100px" onClick="SelectMoveRows(document.Example.FeatureCodes,document.Example.Features)"><br>
<input type="Button" value="Add All>>" style="width:100px" onClick="selectAll(document.Example.Features);SelectMoveRows(document.Example.Features,document.Example.FeatureCodes)"><br>
<br>
<input type="Button" value="<< Remove All" style="width:100px" onClick="selectAll(document.Example.FeatureCodes);SelectMoveRows(document.Example.FeatureCodes,document.Example.Features)">
</td>
<td>
<select name="FeatureCodes" size="9" MULTIPLE>
<option value="1">Row 1</option>
<option value="3">Row 3</option>
</select>
</td>
</tr>
</table>
</form>
于 2012-10-20T07:01:22.027 回答
2
HTML ->
<div>
<select id="first" multiple="true">
<option value="something@something.com"> something@something.com </option>
<option value="something@something.com"> something@something.com </option>
<option value="something@something.com"> something@something.com </option>
<option value="something@something.com"> something@something.com </option>
<option value="something@something.com"> something@something.com </option>
</select>
</div>
<div class="mid">
<button class='add'> > </button>
<button class='remove'> < </button>
<button class='add-all'> >>> </button>
<button class='remove-all'> <<< </button>
</div>
<div class="end">
<select id="second" multiple="true">
</select>
</div>
<div style="clear:both;"></div>
jQuery ->
$('.add').click(function(){
$('#first option:selected').appendTo('#second');
});
$('.remove').click(function(){
$('#second option:selected').appendTo('#first');
});
$('.add-all').click(function(){
$('#first option').appendTo('#second');
});
$('.remove-all').click(function(){
$('#second option').appendTo('#first');
});
于 2012-10-20T07:01:46.900 回答
0
你可以使用这样的东西。它免费且简单,可以做你想做的事。不要发明轮子。
例子:
<select id="example" name="example" multiple="multiple">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
<option value="4">Option 4</option>
<option value="5">Option 5</option>
</select>
jQuery 代码将是:
$(document).ready(function(){
$("#example").multiselect();
});
于 2012-10-20T06:58:55.053 回答
0
请检查这个小提琴。
HTML
<select id="sel1" multiple="multiple">
<option value="something@something.com"> something@something.com </option>
<option value="something@something.com"> something@something.com </option>
<option value="something@something.com"> something@something.com </option>
<option value="something@something.com"> something@something.com </option>
<option value="something@something.com"> something@something.com </option>
</select>
<button id='add'> > </button>
<button id='remove'> < </button>
<button id='multi_add'> >>> </button>
<button id='multi_remove'> <<< </button>
<select id="sel2" multiple="multiple">
</select>
jQuery代码
$('#multi_add').click(function(){
//$('#sel2 option').remove(); //If you want to remove previous option
$('#sel1 option').each(function(){
if($(this).is(':checked')){
$('#sel2').append($(this).clone());
$(this).remove(); //If you want to remove from current list
}
});
});
$('#multi_remove').click(function(){
//$('#sel1 option').remove(); //If you want to remove previous option
$('#sel2 option').each(function(){
if($(this).is(':checked')){
$('#sel1').append($(this).clone());
$(this).remove(); //If you want to remove from current list
}
});
});
$('#add').click(function(){
$('#sel1 option:selected').appendTo('#sel2');
});
$('#remove').click(function(){
$('#sel2 option:selected').appendTo('#sel1');
});
于 2012-10-20T07:11:18.643 回答