我有一个下拉字段,如果选择了任何项目,它将被禁用,之后我提交表单,但然后(提交后)下拉字段没有任何值,我想要提交后的值,但我的下拉字段为空。
感谢您的帮助, (对不起我的英文)
你好。我的问题仍然存在,但无论如何,谢谢;为了使我的代码更清晰:
code: <tr>
<td class="tbl_entry_form_title"><%=DTask.LU_TECHNICIAN_TITLE%> :</td>
<td class="tbl_entry_form_input">
<c:if test="${isTechnicianAdmin eq false}">
<c:forEach var="current" items="${technicianTitleItems}">
<c:if test="${current.value eq taskBadrItem.lu_technician_title}">
<input name="lu_technician_title" value="${current.value}" onclick="
<c:if test="${salesCustomerResult > 0}">alert('something')</c:if>
"/></c:if>
</c:forEach></c:if><c:if test="${isTechnicianAdmin eq true}">
<select name="lu_technician_title" class="select_box" onclick=" <c:if
test="${salesCustomerResult > 0}">alert('something')</c:if> ">
<c:forEach var="current" items="${technicianTitleItems}"><option
value="<c:out value="${current.value}" />"<c:if test="${current.value
eq taskBadrItem.lu_technician_title}"> selected="selected"
</c:if>>
<c:out value="${current.title}"/></option></c:forEach></select>
</c:if></td> </tr>
答案 0 :(得分:2)
假设您使用javascript来禁用下拉列表,您可以将所选值复制到隐藏字段,以便将其与表单一起提交
答案 1 :(得分:0)
您无法获取已禁用字段的值。您可以做的一件事是通过javascript保存隐藏字段中选择框的选择,然后您可以在提交表单后读取该隐藏字段的值。
示例:强>
<select name="whatever" id="whatever" onchange="document.getElementById('hdn').value = this.value;">
<option value="value">Value</option>
<option value="value">Value</option>
<option value="value">Value</option>
<select>
<input type"hidden" id="hdn" />
现在,在您的脚本中,您可以通过hdn
隐藏字段名称读取所选选项的值。
注意:在HTML标记中使用Javascript很糟糕,但是您可以使用jQuery来显示不引人注目的javascript。
jQuery示例:
$(function(){
$('#whatever').change(function(){
$('#hdn').val($(this).val());
});
});
在这种情况下,您不需要将javascript代码放在html中(本例中的选择框)。
希望有所帮助。