我在JSF中有一个autoComplete输入字段。
我的JSP代码
<h:form id="setupValue">
<input type="text" id="department" name="department"/>
<script>
$("#department").autocomplete("getdept.jsp",{minChars: 4});
</script>
</h:form>
和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);
}
如何将department
发送到隐藏字段并将deptName
显示到inputText字段?
由于
答案 0 :(得分:1)
你试过这样的吗?
$("#department").autocomplete({
source: "getdept.jsp",
minLength: 4,
select: function(event, result) {
$("#hiddenfield").val(result)
}
});
显然,获得价值的是$("#hiddenfield").val()