Advertisement
Guest User

Old Javascript

a guest
Apr 11th, 2011
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     $("input.auto").keyup(function() {
  2.         var length = $(this).val().length;
  3.         // check to see if there are more than four characters in the input field
  4.         if (length > 3) {
  5.             //when user enters text, checks and retrieves matche tags
  6.             $("#messages").hide();
  7.             $("#messages").removeClass().addClass('loading').text('loading suggestions').fadeIn();
  8.             var type = $(this).attr('id');
  9.             switch (type) {
  10.                 case 'org-name' : var url = "/admin/orgList";
  11.                 break;
  12.                 case 'org-parent' : var url = "/admin/orgList/parents";
  13.                 break;
  14.                 case 'agency-name' : var url = "/admin/orgList/agencies";
  15.                 break;
  16.                 case "comm-name" : var url = "/admin/orgList/comms";
  17.                 break;
  18.                 case "occ-name" : var url = "/admin/occList";
  19.             }
  20.             //verify entered username
  21.             $.post(url,{ term:$(this).val() } ,function(data) {
  22.                 // if no suggestions are returned
  23.                 if (data=='No matches') {
  24.                     $("#messages").fadeTo(200,0.1,function() {
  25.                         $(this).removeClass().addClass('failure').fadeTo(900,1).html(data);
  26.                     });
  27.                 // if suggestions are returned
  28.                 } else {
  29.                     $("#messages").removeClass().addClass('success').html(data).animate({height: '250px', opacity:'1'},{queue:false, duration:1500, easing: 'easeOutBounce'});
  30.                 }
  31.             });
  32.          }
  33.     });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement