I want to add different autocompletes for different inputs. For example I have the following two input fields:
<input type="text" id="firstname" name="firstname" placeholder="Max" required />
<input type="text" id="lastname" name="lastname" placeholder="Mustermann" required />
So I currently add different autocompletes as follows:
$( document ).ready(function() {
$( '#firstname' ).autocomplete({
source: 'autocomplete_firstname.php',
minLength: 1
});
$( '#lastname' ).autocomplete({
source: 'autocomplete_lastname.php',
minLength: 1
});
});
That works fine for me, but maybe is there a better way like a parameter? So that I can use only one class on autocomplete fields and only one .php-file which return the same result?