jquery:将项目从一个列表移动到另一个列表,并从该列表中收集多个数据


jquery: Moving items from one list to another and collect multiple data from that list

我的HTML表单中有两个select控件。

    <form name="frmMultiple" id="frmMultiple" method="get" action="MovingItemsFromList.php">
    <table border="0" cellpadding="5" cellspacing="0">
    <tr>
        <th align="left" valign="top">Select:</th>
        <th>&nbsp;</th>
        <th align="left" valign="top">Selected:</th>
    </tr>
    <tr>
        <td align="left" valign="top">
            <select id="cboCountryID" name="cboCountryID" multiple="multiple" style="width:200px;" size="10">
                <option value="1">Afghanistan</option>
                <option value="3">America</option>
                <option value="3">Albania</option>
                <option value="4">Algeria</option>
                <option value="5">American samoa</option>
            </select>
        </td>
        <td align="center" valign="middle">
            <input type="button" id="btnMoveRight" name="btnMoveRight" value=">>" />
            <input type="button" id="btnMoveLeft" name="btnMoveLeft" value="<<" />
        </td>
        <td align="left" valign="top">
            <select id="cboCountryIDSelected" name="cboCountryIDSelected" multiple="multiple" style="width:200px;" size="10">
            </select>
        </td>
    </tr>
    <tr><td colspan="2"><input type="submit" id="btnSubmit" name="btnSubmit" value="Show" /></td></tr>
    </table>
    </form>

我可以使用jQuery:轻松地将数据从一个选择控件/组合框移动到另一个

    $(document).ready(function(){
        $('#cboCountryID').dblclick(function(){return !$('#cboCountryID option:selected').appendTo('#cboCountryIDSelected');});
        $('#btnMoveRight').click(function(){return !$('#cboCountryID option:selected').appendTo('#cboCountryIDSelected');});
        $('#cboCountryIDSelected').dblclick(function(){return !$('#cboCountryIDSelected option:selected').appendTo('#cboCountryID');});
        $('#btnMoveLeft').click(function(){return !$('#cboCountryIDSelected option:selected').appendTo('#cboCountryID');});
    });

问题是,我想使用PHP从我的第二个选择控件/组合框中收集数据。如果我在控件名称中使用[],它将停止移动数据。有人能给我什么解决方案吗?

请确保只将名称而不是id更改为cboCountryIDSelected[]

<select id="cboCountryIDSelected" name="cboCountryIDSelected[]" multiple="multiple" style="width:200px;" size="10"></select>