【发布时间】:2015-07-24 10:04:27
【问题描述】:
我正在尝试在 jsp 中执行自动完成文本框。但我不知道如何包含从数据库中检索到的所有数据以用于匹配用户键入的值。请帮助,非常感谢。
<%
String FRUIT= "";
TEST.makeConnection();
String SQL = "SELECT * FROM TB_FRUIT WITH UR";
TEST.executeQuery(SQL);
while(TEST.getNextQuery())
{
FRUIT= TEST.getColumnString("FRUIT_DESCP");
}
TEST.takeDown();
%>
<html>
<head>
<meta charset="utf-8">
<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>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
$(function() {
var availableTags = [
//how can i include the data(FRUIT) from database to put in here?
"Apple", // i hardcode this to do testing for my current autocomplete textbox
"Avocado", // i hardcode this to do testing for my current autocomplete textbox
"Banana",// i hardcode this to do testing for my current autocomplete textbox
"Durian",// i hardcode this to do testing for my current autocomplete textbox
"Mango",// i hardcode this to do testing for my current autocomplete textbox
];
$( "#tags" ).autocomplete({
source: availableTags
});
});
</script>
<body>
<div class="ui-widget">
<label for="tags">Tags: </label>
<input id="tags">
</div>
</body>
</html>
【问题讨论】:
标签: jquery jsp autocompletebox