这是我的jsp页面的代码,它显示了一个带有columns的窗口。每个列对应一个表单
<%@include file="/WEB-INF/jsp/include/pagedirectives.jsp"%>
<div style="background: #D6E8FF; padding: 10px;" class="advanced_search">
<%@include file="/WEB-INF/jsp/include/page.topmessagebox.jsp"%>
<table class="form" cellspacing="0" id="requestSubmissionEform">
<tbody>
<tr>
<td class="label"><b>Label</b></td>
<c:forEach var="i" begin="1" end="5" step="1" varStatus ="status">
<th id="form_${i}" class="label" align="left"><b>Form ${(pageNumber * 5) + i}</b></th>
</c:forEach>
</tr>
<c:forEach items="${eformDetailsList}" var="eformDetails"
varStatus="status">
<tr id="serviceTypeWithEform">
<td class="label">
<label for="${eformDetails.id}_0"><c:out value="${eformDetails.label}" /></label>
<input type="hidden" id="label_${eformDetails.id}_0" value="${eformDetails.label}" name="label_0"></input>
<input type="hidden" id="index_${eformDetails.id}_0" value="${eformDetails.id}" name="index_0"></input>
</td>
<c:if test="${eformDetails.controlType==1}">
<td id="Col0" style="visibility: visible;">
<input id="eformDetail_${eformDetails.id}_0" class="eformDetail" type="text" value="" name="form_0"></input>
</td>
<td id="Col1" style="visibility: visible;">
<input id="eformDetail_${eformDetails.id}_1" class="eformDetail" type="text" value="" name="form_1"></input>
</td>
<td id="Col2" style="visibility: visible;">
<input id="eformDetail_${eformDetails.id}_2" class="eformDetail" type="text" value="" name="form_2"></input>
</td>
<td id="Col3" style="visibility: visible;">
<input id="eformDetail_${eformDetails.id}_3" class="eformDetail" type="text" value="" name="form_3"></input>
</td>
<td id="Col4" style="visibility: visible;">
<input id="eformDetail_${eformDetails.id}_4" class="eformDetail" type="text" value="" name="form_4"></input>
</td>
</c:if>
</tr>
</c:forEach>
<c:if test="${empty eformDetailsList}">
<tr id="serviceTypeWithNoEform">
<td><b>There is no eform associated with this Service Type</b></td>
</tr>
</c:if>
</tbody>
</table>
这是用于从jsp页面获取值的jquery:
var labels0=$('input[name="label_0"]').map(function(){
return $(this).val() }).get();
var index0=$('input[name="index_0"]').map(function(){
return $(this).val() }).get();
var fields0 = $('input[name="form_0"]').map(function(){
return $(this).val() }).get();
var fields1 = $('input[name="form_1"]').map(function(){
return $(this).val() }).get();
var fields2 = $('input[name="form_2"]').map(function(){
return $(this).val() }).get();
var fields3 = $('input[name="form_3"]').map(function(){
return $(this).val() }).get();
var fields4 = $('input[name="form_4"]').map(function(){
return $(this).val() }).get();
点击保存后,我保存了值。当我再次打开表单时,我希望保存的值重新出现在我的文本框中。有没有办法将值重新设置回地图?
答案 0 :(得分:0)
(我认为你应该用jsp来做..) 无论如何,假设你有js数组:
var label_0_values = ['value 1', 'value 2', ...];
使用jQuery,你会像这样填充:
$('input[name="label_0"]').each(function(i){
$(this).val(label_0_values[i]);
});
您的其他输入也一样
希望这会有所帮助。干杯