我使用JSP,我想传递两个参数以及jquery自动完成。我的第二个参数是选择框的值。我使用了以下代码,但只获得了选项中的第一个值。我检查了返回选择框值的函数,它仅在页面加载时被调用。有什么办法可以解决我的问题吗?
/* inside my page */
jQuery(function() {
$("#branch").autocomplete("getbranchdetails.jsp", {
extraParams: {
filter: getDropdownValue()
}
});
});
function getDropdownValue() {
var compId=document.getElementById("company").value;
return compId;
}
/* inside getbranchdetails.jsp */
<%
String company=request.getParameter("filter");
System.out.println("company :"+company);
getbranchdetails db=new getbranchdetails();
String query = request.getParameter("q");
List<String> agent = db.getData(query,brtype);
Iterator<String> iterator = agent.iterator();
while(iterator.hasNext()) {
String agents = (String)iterator.next();
out.println(agents);
}
%>
我也尝试了以下链接,但没有成功 http://123code.blogspot.in/2010/09/jquery-autocomplete-plugin-using.html
最佳答案
更改此:
$("#branch").autocomplete("getbranchdetails.jsp");
extraParams: {
filter: getDropdownValue()
}
});
至
$("#branch").autocomplete("getbranchdetails.jsp", {
extraParams: {
filter: getDropdownValue()
}
});
关于JSP中jquery自动完成多个参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10309651/