Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

103
Views
SharePoint Form Field Titles and JavaScript

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:

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:

$(function() {

$("input[title='FIELD1']").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 > 0) {
            var entry = entries.shift();        
            var item = { value: entry.ResourceName, label: entry.ResourceName};
            items.push(item);
        }
        response(items);
    });
  },
  minLength: 3
});
$("input[title='FIELD1']").attr("title", "Enter 3 characters to search");


    $(".ui-autocomplete-input").on("autocompletechange", function(e, u){
    $(this).focus();
    $(this).change(); 
}); 
});

In this example, I've explicitly defined 'FIELD1' as the field to apply the function to and all is well. But when i substitute:

let varField = 'FIELD1'
console.log(varField);
$("input[title=varField]").autocomplete.....

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,

If Field title = FIELD1, set varField to 'FIELD1' If Field title = FIELD2, set varField to 'FIELD2' etc..

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.

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.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!