![](/img/trans.png)
[英]How to get selected value in one select option and based on that, fetch data from MySQL table to show another select option in the same form
[英]How can I transfer the selected table from a list of database tables inside <select></select> form to another <select></select> form
這是我目前的代碼:
<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>
如何將選定的表格從左側下拉列表中轉移到右側,反之亦然?
我用我認為你正在尋找的東西創造了一個小提琴 。 使用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.