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.

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)"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.