I have a server done with NodeJs, it sends an array to the following view. I'am trying to use this array for a field auto completion using jquery UI.
Here is the code :
server side :
<!DOCTYPE html>
<html lang="fr">
<head>
<script src="https://code.jquery.com/jquery-3.1.1.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<meta charset="UTF-8">
<title>Formulaire </title>
<script>
$( "#depart" ).autocomplete({
source: <%=autoComp%>
});
</script>
</head>
<body>
<form action="/result" method="post">
Départ:<input id="depart" type="text" name="depart" ><br>
Arrivée: <input type="text" name="arrivee"> <br>
<input type="submit" value="Chercher un itinéraire">
</form>
<%
if(erreur){
%> <p>Erreur lors de la saisie des stations</p>
<%
}
%>
<p> <%=autoComp[0]%> </p>
</body>
</html>
This line :
<%=autoComp[0]%>
prints the first element of autoComp as expected, but the way i associate auto completion with the autoComp array doesn't seem to work. I guess the error is from :source: <%=autoComp%>
but how am i supposed to do to make auto completion use the array autoComp to fetch his values ?
via StuYYY
No comments:
Post a Comment