I want to create an autocomplete input text for the list of city. I am getting output in the JSP page (checked) but I don't know how to get back response to requested page in edit text suggestion.
Here is my code :
index.jsp (A file with edit text and JavaScript plugin)
$("#city").autocomplete("indexEditText.jsp");
<html>
<link rel="stylesheet" type="text/css" href="https://pengoworks.com/workshop/jquery/lib/jquery.autocomplete.css" />
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script src="https://pengoworks.com/workshop/jquery/lib/jquery.autocomplete.js"></script>
</head>
<body>
<h3>City</h3>
<input type="text" id="city" name="city"/>
</body>
</html>
indexEditText.jsp
<%
List<String> l = ConnectionProvider.getData(request.getParameter("city"));
Iterator<String> iterator = l.iterator();
String[] city=null;
int i=0;
while(iterator.hasNext()) {
city[i]= (String)iterator.next();
out.println(city[i]);
i++;
}
/* String json = new Gson().toJson(l);
response.getWriter().write(json); */
%>
We can use the
<datalist>
tag of HTML5 and fill the data in the list with the help of script/code whatever you use to retrieve.Here I used java and JSP page for the view.