radio只能存一个值,考试系统需要,建立一个隐藏域
<div style="float: left;">题目:</div>
<c:forEach items="${radioList }" var="radio"
varStatus="status">
<c:if test="${ status.count==1}">
<div class="layui-form-item" id="qu${ status.count}">
<div class="layui-input-inline">
<c:if test="${radio.test_flag==1}">
(单选)
<input type="hidden" name="optionId" id="quAswer${radio.test_id }" />
</c:if>
<c:if test="${radio.test_flag==2}">
(多选)
</c:if>
<c:if test="${radio.test_flag==3}">
(判断)
<input type="hidden" name="optionId"
id="quAswer${radio.test_id }" />
<!-- huich-->
</c:if>
<div class="layui-col-md9" style="text-align: center; font-size: 20px;color: #000000;font-weight: none">${radio.test_name }</div>
<br>
<div>————————————————————————————————</div>
<br>选项:
</div>
<br>
<c:forEach items="${optionList }" var="option">
<c:if test="${option.test_id==radio.test_id }">
<c:if test="${radio.test_flag==1}">
<div class="layui-form-item">
${option.option_type }: ${option.option_content } :
<input type="radio" name="optionValue" value="${option.option_id }" class="layui-input" id='${radio.test_id }' lay-filter="optionId">
</div>
</c:if>
<c:if test="${radio.test_flag==3}">
<div class="layui-form-item">
${option.option_type }: ${option.option_content } : <input
type="radio" name="optionValue"
value="${option.option_id }" class="layui-input"
id='${radio.test_id }' lay-filter="optionId">
</div>
</c:if>
<c:if test="${radio.test_flag==2}">
<div class="layui-form-item">
${option.option_type }: ${option.option_content } : <input
type="checkbox" name="optionId"
value="${option.option_id }" class="layui-input">
</div>
</c:if>
</c:if>
</c:forEach>
<!-- 隐藏域 -->
<div class="layui-form-item">
<input type="hidden" name="testId"
value="${radio.test_id }" />
</div>
</div>
</c:if>
在
用中间隐藏域进行传值
form.on('radio(optionId)', function(data){
var quId = data.elem.id;
$("#quAswer"+quId).val(data.value);
});