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
<form action="#" autocomplete="on">
<select name="gid" id="gid">
	<option value="select">Select</option>
	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>
<%	}	%>
<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.

6 Years
Discussion Span
Last Post by urtrivedi

I assume gid is number

so pass one more parameter test.jsp?gid=1&gidlist=-1,2,3,
track entered ids using javascript store it some where.

then in your query you may write

"select gid, sgg_eng_nm from test where gid not in ($gidlist)"
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.