Reputation: 14731
I hava a autoComplete input field in JSF.
My JSP code
<h:form id="setupValue">
<input type="text" id="department" name="department"/>
<script>
$("#department").autocomplete("getdept.jsp",{minChars: 4});
</script>
</h:form>
and in getdept.jsp
DepartmentMB dept = new DepartmentMB ();
String query = request.getParameter("q");
List<String> dep = dept.getData(query);
Iterator<String> iterator = dep .iterator();
while(iterator.hasNext()) {
String department = (String)iterator.next();
String deptName=(String)it.next();
out.println(deptName);
}
How can I send department
to a hidden field and display deptName
to inputText field?
Thanks
Upvotes: 1
Views: 788
Reputation: 121998
Have you tried like this ?
$("#department").autocomplete({
source: "getdept.jsp",
minLength: 4,
select: function(event, result) {
$("#hiddenfield").val(result)
}
});
Obviously getting value is $("#hiddenfield").val()
Upvotes: 1