[英]How can I transfer the selected table from a list of database tables inside <select></select> form to another <select></select> form
This is my current code: 这是我目前的代码:
<div class="column" id="tbDiv">
<p><b>TABLES</b></p>
<select name="List of Tables" size="25" multiple id='table1' name='table1' title='List of Tables' class='inputbox'>
<option>Tables will be listed here...</option></select>
</div>
</td>
<td>
<div class="column">
<button onclick="myFunction1()" style="float:right; margin-right:0px;" id="submit1"><<</button>
<button onclick="myFunction2()" style="float:right; margin-right:0px;" id="submit">>></button>
</div>
</td>
<td>
<div class="column">
<p><b>TABLE(S) TO SYNC</b></p>
<select name="List of Tables" size="25" multiple name='table1' title='List of selected tables' name="List of Tables" size="20" class='inputbox'>
<option>. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . </option>
</select>
</div>
</td>
How can I transfer a selected table from the left dropdownlist to the right, or vice versa? 如何将选定的表格从左侧下拉列表中转移到右侧,反之亦然?
I have created a Fiddle with what I think you are looking for. 我用我认为你正在寻找的东西创造了一个小提琴 。 Using jQuery is very simple to do it.
使用jQuery非常简单。
$(document).ready(function(){
$("#add").click(function(){
$("#tables option:selected").each(function(){
$(this).clone().appendTo("#tables_to_sync");
$(this).remove();
});
});
$("#remove").click(function(){
$("#tables_to_sync option:selected").each(function(){
$(this).clone().appendTo("#tables");
$(this).remove();
});
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.