简体   繁体   English

如何从内部的数据库表列表中传输选定的表 <select></select> 形成另一种形式 <select></select> 形成

[英]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.

相关问题 如何在一个 select 选项中获取选定值,并在此基础上,从 MySQL 表中获取数据,以相同形式显示另一个 select 选项 - 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 在另一页的表单内显示选定的值(标签选择) - Display the selected value (tag select) inside the form on another page 如何创建一个带有2个select标签的表单,将这个select中的元素添加到另一个select中,以及如何处理表单提交? - How to create a form with 2 select tag, adding element from this select to another select, and handle form submission? 只有选择了另一个选择(父项)后,我才能显示选择列表 - How i can show a select list only after another select (parent) has been selected 我怎样才能把选择的选项 <select>从动态生成的表单到输入字段 - How can I put the selected option of a <select> from a dynamically generated form into an input field 动态选择列表AJAX并通过发布表单插入数据库表 - dynamic select list AJAX and insertion in database table through posting form 如何从长选择选项列表中拉出所选值? - How to pull selected value form long select options list? 如何在提交表单后自动选择列表菜单中的选定项目? - How to automatically select the selected item in list menu after submitting the form? 如何从表单中选择选项时填充一些文本字段:选择将项目作为对象列表? - How can i populate some textfield on selection of an option from the form:select having items as object list? 我如何在Dojo form.select选项中设置选中 - how do i set selected in Dojo form.select option
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM