here code:
<%@ page language="java" contenttype="text/html; charset=utf-8" pageencoding="utf-8"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>insert title here</title> <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script> </head> <body> <sql:setdatasource var="snapshot" driver="com.mysql.jdbc.driver" url="jdbc:mysql://localhost/demo" user="root" password="root"/> <sql:query datasource="${snapshot}" var="list"> select * emoloyeesample; </sql:query> <form action="some.jsp" method="get"> <select name="id" id="name" onkeyup="dosomething(this.value);"> <option value="0">select employee</option> <c:foreach var="employee" items="${list.rows}"> <option value="${employee.id}">${employee.name}</option> </c:foreach> </select> <input type="submit" value="submit" > <script> $(function() { var availabletags=${list} $( "#name" ).autocomplete({ source: availabletags }); }); </script> </form> </body> </html> here getting values database in ${list} , values shown in drop down list requirment when user press s name having initial s must shown in drop down list.
you can use datalist here
please consider if number of field huge might not solution
Comments
Post a Comment