我使用JSP,我想傳遞兩個參數以及jquery自動完成。我的第二個參數是選擇框的值。我已經使用了下面的代碼,但只獲得了選項中的第一個值。我檢查了返回選擇框值的函數,它只在頁面加載時被調用。有什麼方法可以解決我的問題嗎?jquery自動完成JSP中的多個參數
/* 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
感謝Mark Schultheiss,這是我在此輸入的錯誤。我現在在這個問題中編輯了它。 – arjuncc 2012-04-28 03:33:35
@arjuncc - 您的問題目前沒有反映出帶有額外括號的聲明。 – 2012-04-30 12:34:56
將其更改爲感謝幫助 – arjuncc 2012-05-02 04:02:33