The following is the output of my program.

select country
Image 1

After selecting any item from the left side list box click on the ( >) button.

add country
Image 2

If you click on the ( >> ) button then all items in left side list box will move to the right side list box.

select all country
Image 3

After selecting any item in right side list box if you click on the ( < ) then:

select country left side
Image 4

If you click on the ( << ) then:

select all country left side
Image 5

The following is my aspx where I wrote the jQuery for this:

  1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head runat="server">
  5. <title>Move Item From One List To Another List Using jQuery</title>
  6. <script src="jquery-1.7.1.js" type="text/javascript"></script>
  7. <script type="text/javascript">
  8. $(document).ready(
  9. function() {
  10. $('#btnAdd').click(
  11. function(e) {
  12. $('#list1 > option:selected').appendTo('#list2');
  13. e.preventDefault();
  14. });
  15. $('#btnAddAll').click(
  16. function(e) {
  17. $('#list1 > option').appendTo('#list2');
  18. e.preventDefault();
  19. });
  20. $('#btnRemove').click(
  21. function(e) {
  22. $('#list2 > option:selected').appendTo('#list1');
  23. e.preventDefault();
  24. });
  25. $('#btnRemoveAll').click(
  26. function(e) {
  27. $('#list2 > option').appendTo('#list1');
  28. e.preventDefault();
  29. });
  30. });
  31. </script>
  32. </head>
  33. <body11
  34. <form id="form1" runat="server">
  35. <table cellpadding="4" cellspacing="4" width="90%" align="center" style="border: solid 2px gray;
  36. background-color: #ADD8E6;">
  37. <tr>
  38. <td height="10px">
  39. </td>
  40. </tr>
  41. <tr>
  42. <td align="center">
  43. <asp:ListBox ID="list1" runat="server" Width="250px" Height="100px">
  44. <asp:ListItem Value="India">India</asp:ListItem>
  45. <asp:ListItem Value="Australia">Australia</asp:ListItem>
  46. <asp:ListItem Value="USA">USA</asp:ListItem>
  47. <asp:ListItem Value="Japan">Japan</asp:ListItem>
  48. <asp:ListItem Value="Brazil">Brazil</asp:ListItem>
  49. </asp:ListBox>
  50. </td>
  51. <td align="center">
  52. <input type="button" id="btnAdd" value=">" style="width: 50px;" /><br />
  53. <input type="button" id="btnAddAll" value=">>" style="width: 50px;" /><br />
  54. <input type="button" id="btnRemove" value="<" style="width: 50px;" /><br />
  55. <input type="button" id="btnRemoveAll" value="<<" style="width: 50px;" />
  56. </td>
  57. <td align="center">
  58. <asp:ListBox ID="list2" runat="server" Width="250px" Height="100px"></asp:ListBox>
  59. </td>
  60. </tr>
  61. <tr>
  62. <td height="10px">
  63. </td>
  64. </tr>
  65. </table>
  66. </form>
  67. </body>
  68. </html>