当前我在同一页面中有一个JSP页面,我已经编写了JQuery AutoComplete,我需要将该属性价值传递到Action类。
jQuery:
$("#mednameautobox").autocomplete("/ConsultationAutoCompleteAction.do?mode=getAutoCompletionList¶meter=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>
动作类:
String FormValue=request.getParameter("forvalue");
System.out.println("form value in AutoCompleteAction: "+FormValue);
但是,我的formvalue值我却无效。如果我错了,请建议我其他任何方法来实现它或纠正我。
- 您应该URL对您的URL编码
- 您应该确保
forvalue
是URL-SAFE(由#1处理( - 最终问题是您如何检索
<select>
值
要获得HTML <select>
值,您不能简单地要求值:
var selector = document.getElementById('id_of_select');
var value = selector[selector.selectedIndex].value;