2017-04-21 38 views
0

目前我在同一页面中有一个Jsp页面我写了jquery Autocomplete,并且需要将该属性值传递给操作类。如何在Jquery中获取Jsp Struts属性值自动完成

的jQuery:

$("#mednameautobox").autocomplete("/ConsultationAutoCompleteAction.do?mode=getAutoCompletionList&parameter=Med Name&forvalue"+document.getElementById("FormId").value); 

JSP:

<td> 
<html:text styleId="mednameautobox" property="mednameautobox" value="SEARCH MEDICINE NAME" styleClass="textBox textBoxMedium" disabled="<%=viewmode%>" onblur="javascript:searchfromselectbox('Med Name');"/> 
</td> 
<td width="20%" class="formLabel">Form:<span class="mandatorySymbol">*</span></td> 
    <!-- <td class="formLabel">City: </td> --> 
    <td> 
    <html:select name="frmPatientDetails" property ="formlist" styleId="FormId" styleClass="selectBox selectBoxMedium" disabled="<%=viewmode%>" onchange="getDropDown('medicine','MedicineId')"> 
    <html:option value="">Select from list</html:option> 
    <html:optionsCollection name="alformlist" label="cacheDesc" value="cacheId"/> 
    </html:select> 
    </td> 

Action类:

String FormValue=request.getParameter("forvalue"); 
       System.out.println("form value in AutoCompleteAction: "+FormValue); 

但FormValue值我得到空。 建议我采取任何其他方式来实现它或纠正我,如果我错了。

回答

0
  1. 你应该URL编码您的网址
  2. 你应该确保forvalue是URL安全的(通过#处理1)
  3. 最终的问题是如何获得一个<select>

要获得HTML <select>的值,您不能简单地要求该值:

var selector = document.getElementById('id_of_select'); 
var value = selector[selector.selectedIndex].value;