title: SharePoint Form Field Titles and JavaScript
body: <p>Good afternoon all!  Thanks so much for looking.  I've got a JavaScript issue here that I'm not sure where I'm going wrong.  Here's the scenario:</p>
  <p>I have a SP Form with several custom fields that need to have an auto-complete function applied to them.  There is a REST call that populates the auto-complete, that part works great.  The issue, however, lies with attempting to assign the field TITLE to a variable.  Here's what I've got so far:</p>
  <pre><code>$(function() {
  
  $(&quot;input[title='FIELD1']&quot;).autocomplete({
    source: function( request, response ) {
      var term = request.term;
      var restUrl = PWATABLEURL
      
      XXX.PO.Data.loadJSON(restUrl, function (data) {
          var items = [];
          var entries = data.value;
          
          while (entries.length &gt; 0) {
              var entry = entries.shift();        
              var item = { value: entry.ResourceName, label: entry.ResourceName};
              items.push(item);
          }
          response(items);
      });
    },
    minLength: 3
  });
  $(&quot;input[title='FIELD1']&quot;).attr(&quot;title&quot;, &quot;Enter 3 characters to search&quot;);
  
  
      $(&quot;.ui-autocomplete-input&quot;).on(&quot;autocompletechange&quot;, function(e, u){
      $(this).focus();
      $(this).change(); 
  }); 
  });
  </code></pre>
  <p>In this example, I've explicitly defined 'FIELD1' as the field to apply the function to and all is well.  But when i substitute:</p>
  <pre><code>let varField = 'FIELD1'
  console.log(varField);
  $(&quot;input[title=varField]&quot;).autocomplete.....
  </code></pre>
  <p>it fails with no real help from the console messages--it just doesnt work.  The plan was to set up a case switch where it would work like,</p>
  <p>If Field title = FIELD1, set varField to 'FIELD1'
  If Field title = FIELD2, set varField to 'FIELD2'
  etc..</p>
  <p>In this way each field we needed to apply the auto-complete function to would get the same block of code without using repeating sections in the script.</p>
  <p>I'm still plugging away, but i feel like I'm missing something easy here as i can't even get to a single variable, much less multiple.  Any and all input is appreciated and as always, thanks to the community for taking the time.</p>