开发者

move from Listbox to other ListBox

I have the following code:

HTML

<table width="30%" border="0">
<tr>
    <td colspan="4" align="center">
<asp:Label ID="Label12" runat="server" CssClass="label" Text="Responsabilidades"></asp:Label>
    </td>
</tr>
<tr>
    <td colspan="4">
        <asp:ListBox ID="lstDisponibles" runat="server" Width="140px" 
            Height="110px" SelectionMode="Multiple">
            <asp:ListItem>s</asp:ListItem>
            <asp:ListItem>w</asp:ListItem>
            <asp:ListItem>f</asp:ListItem>
        </asp:ListBox>
    </td>
    <td>
        <input id="imgAdd" type="image" src="../../images/control_fastforward.png" value="button" />                                   
        <br />
        <input id="imgRem" type="image" src="../../images/control_rewind.png" value="button" />                                   
    </td>
    <td>
       <asp:ListBox ID="lstUsuario" runat="server" Width="140px" Height="110px" SelectionMode="Multiple">
        </asp:ListBox>
    </td>
    <td></td>
</tr>

</table>

and the jQuery Code:

$(document).ready(function () {
    $("#imgAdd").click(function () {
        $("#lstDisponibles > option[@selected]").appendTo("#lstUsuario");
    });
    $("#imgRem").click(function () {
        $("#lstUsuario > option[@selected]").appendTo("#lstDisponibles");
    });
}); 

I want to move from lstDisponibles to lstUsuarios but this dont work. I can find any example using asp.net listbox element. I test using html tag but this cannot be useful.

Anyone can please helpme with this.

开发者_运维百科

Thanks.


Try changing your selector from:

#lstDisponibles > option[@selected]

to:

#lstDisponibles > option:selected

Add would be:

$("#lstUsuario").append($("#lstDisponibles > option:selected"));


They syntax should be

$("#lstDisponibles > option:selected")

Also be careful that .net isn't changing your IDs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜