Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 12th, 2012  |  syntax: None  |  size: 2.47 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. passing jquery ui autocomplete selection into variable
  2. $("#name").blur(function() {
  3.         var standards_name = $("#name").val();
  4.         var standards_link = $("#standardslink");
  5.         var update_log = $("#update_log");
  6.         if(jQuery.inArray(standards_name, standards) != -1) {
  7.             if(companyid !== null) {
  8.                 standards_link.attr("href", basic_href + "?standards_name=" + standards_name + "&company_id=" + companyid);
  9.             } else {
  10.                 standards_link.attr("href", basic_href + "?standards_name=" + standards_name);
  11.             }  
  12.             standards_link.css("color","#2EE52B");
  13.         } else if(standards_name == "") {  
  14.             standards_link.removeAttr("href");
  15.             standards_link.css("color","black");
  16.             update_log.hide();
  17.         } else {
  18.             standards_link.removeAttr("href");
  19.             standards_link.css("color","#FF0011");
  20.             update_log.hide();
  21.         }
  22.     });
  23.        
  24. $(function() {
  25.  
  26.         $("#name").autocomplete({
  27.             source: "../autocomplete.php",
  28.             minLength: 2,
  29.             select: function(event, ui) {
  30.             $('#name').val(ui.item.ticker_name);
  31.             $('#mktcap').val(ui.item.mkt_cap);
  32.             var standards_name = ui.item.ticker_name;
  33.             var standards_link = $("#standardslink");
  34.             var update_log = $("#update_log");
  35.             if(jQuery.inArray(standards_name, standards) != -1) {
  36.                 if(companyid !== null) {
  37.                     standards_link.attr("href", basic_href + "?standards_name=" + standards_name + "&company_id=" + companyid);
  38.                 } else {
  39.                     standards_link.attr("href", basic_href + "?standards_name=" + standards_name);
  40.                 }  
  41.                 standards_link.css("color","#2EE52B");
  42.             } else if(standards_name == "") {  
  43.                 standards_link.removeAttr("href");
  44.                 standards_link.css("color","black");
  45.                 update_log.hide();
  46.             } else {
  47.                 standards_link.removeAttr("href");
  48.                 standards_link.css("color","#FF0011");
  49.                 update_log.hide();
  50.             }
  51.             }    
  52.  
  53.         });
  54. });
  55.        
  56. $("#name").attr("standards_name",ui.item.ticker_name);
  57.        
  58. var standards_name = $("#name").attr("standards_name");
  59.        
  60. $("#name").autocomplete({
  61.  source: function (request, response) {
  62. /*Souse code here*/
  63. },
  64. select: function (e, i){
  65. /*Selection code here inorder to get value use i.item.val*/
  66.  
  67. }
  68. })