1

我在 JSF 中有一个自动完成输入字段。

我的 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 字段?

谢谢

4

1 回答 1

1

你试过这样吗?

$("#department").autocomplete({
    source: "getdept.jsp",
    minLength: 4,
    select: function(event, result) { 
        $("#hiddenfield").val(result)
    }
});

显然获得价值是 $("#hiddenfield").val()

于 2013-03-25T08:55:10.240 回答