Guest User

Untitled

a guest
Feb 21st, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 1.74 KB | None | 0 0
  1.     <script type="text/javascript">
  2.         $(document).ready(function()
  3.         {
  4.             $('#boxClear').click(function(){
  5.                 $('#firstFilterSearch').val('');
  6.  
  7.             });
  8.  
  9.             $('#firstFilterSearch').keyup(function()
  10.             {
  11.                 var searchArea = $('#firstList');
  12.                 searchFirstList($(this).val(), searchArea);
  13.             });
  14.  
  15.             $('#firstList').dblclick(function() {
  16.                 assignList();
  17.             });
  18.  
  19.             $('#secondList').dblclick(function() {
  20.                 unassignList();
  21.             });
  22.  
  23.             $('#to2').click(function()
  24.             {
  25.                 assignList();
  26.             });
  27.  
  28.             $('#to1').click(function()
  29.             {
  30.                 unassignList();
  31.             });
  32.         });
  33.            
  34.         // Function for Filtering
  35.         function searchFirstList(inputVal, searchArea)
  36.         {
  37.             var allCells = $(searchArea).find('option');
  38.             if(allCells.length > 0)
  39.             {
  40.                 var found = false;
  41.                 allCells.each(function(index, option)
  42.                 {
  43.                     var regExp = new RegExp(inputVal, 'i');
  44.                     if(regExp.test($(option).text()))
  45.                     {
  46.                         $(option).show();
  47.                     }
  48.                     else
  49.                     {
  50.                         $(option).hide();
  51.                     }
  52.                 });
  53.             }
  54.         }
  55.  
  56.         // function: UnAssignment
  57.         function assignList()
  58.         {
  59.             $('#firstList :selected').each(function(i, selected){
  60.                 // append to second list box
  61.                 $('#secondList').append('<option value="'+selected.value+'">'+ selected.text+'</option>');
  62.                 // remove from first list box
  63.                 $("#firstList option[value='"+ selected.value +"']").remove();
  64.             });
  65.         }
  66.         // function: UnAssignment
  67.         function unassignList()
  68.         {
  69.             $('#secondList :selected').each(function(i, selected){
  70.                 // append to first list box
  71.                 $('#firstList').append('<option value="'+selected.value+'">'+ selected.text+'</option>');
  72.                 // remove from second list box
  73.                 $("#secondList option[value='"+ selected.value +"']").remove();
  74.             });
  75.         }
  76.     </script>
Add Comment
Please, Sign In to add comment