Hi all.
my code is below:
<script type="text/javascript">
function gu_gid() {
var ggid = document.getElementById("gid");
if(ggid.value != "" && ggid.value != "select") {
$().ready(function() {
$("#autocomplete").autocomplete("test.jsp?gid=" + ggid.value, {
max: 50,
width: 300,
matchContains: true,
selectFirst: false
});
});
}
}
</script>
.
.
.
<form action="#" autocomplete="on">
<div>
<select name="gid" id="gid">
<option value="select">Select</option>
<%
Class.forName("org.postgresql.Driver");
String url = "jdbc:postgresql://localhost:8080/test";
Connection conn = DriverManager.getConnection(url, "root", "root");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select gid, sgg_eng_nm from test");
while (rs.next()) {
String str = rs.getString("sgg_eng_nm");
int gid = rs.getInt("gid");
%>
<option value="<%=gid%>"><%=str%></option>
<% } %>
</select>
</div>
<input type="text" name="autocomplete" id="autocomplete" onclick="gu_gid()" />
What I want to do is, when I click item from dropdownlist, get gid.
And then based on gid, when I input some letters in textbox(autocomplete), results are output. But gid is duplication.
For example, I clicked gid="1", and input something -> output well.
And I clicked gid="3", it's searching gid="1" first and then search gid="3".
So how can I try something for preventing duplication?
Thanks in advanced.
Best Regards.
Kevin Lee.