I am totally new in jquery and "code" is not at all my speciality, so my question will may be very trivial as I don't really understand all the parts of the code I write that is made from parts I picked in different tutorials...
- What I need to do :
Build a form with two fields (in a wordpress website) : 1) where user type a few letters and which have to autocomplete according to a list of species which are stored in a .csv file (uploaded in my server) ; 2) a second field where a number (the species unique identifiant) have to appear after the species selected/written in the first field.
How csv file is made : It's a simple .xls table registered in .csv ; the first row is the columns name : "Species", "Identifiant" and the #2 to #14000 rows are species names and id numbers :
Species,Identifiant, Species A,320439, Species B,349450, Species C,43435904, [etc...]
Up to now, I only manage to have a kind of autocomplete form by creating an array with all the species names (see code below), but as I have 14000 species, the array is very big, and the searching process is quite long... And there is no link to the data base and certainly no possibility to automatiquely fill the second field with the species'ID...
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Autocomplete - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
var availableTags = [
"Species A",
"Species B",
"Species C",
[etc...]
];
$( "#tags" ).autocomplete({
source: availableTags
});
} );
</script>
</head>
<body>
<div class="ui-widget">
<label for="tags">Tags: </label>
<input id="tags">
</div>
</body>
</html>
The .csv file which host species names and id is for example named : "reference.csv" and is store at : www.mywebsite/referencials/reference.csv
Could anyone give me clues to indicate this file and the good raws instead of the array implemented in the code ?
Many thanks for the help !