构建动态复选框

时间:2012-02-01 19:27:13

标签: jstl

嘿伙计们我有大约8个fieldSets和Im迭代列表。我想根据ex的每次迭代的值填充复选框。

 <c:if test="${detBean.groupName == 'HEADER_DATA}">

*将该复选框添加到该字段集,依此类推......

    <c:forEach var="detBean" items="${detFields}">
    Display Name -- ${detBean.displayName}
    Field Name -- ${detBean.fieldName} 
    Group Name -- ${detBean.groupName}
    </c:forEach>

<tr>
        <td>
            <div id="displayFields" style="display:block;">
            <fieldset class="det">

                <legend>Header Data</legend>
                <input type="checkbox" name="${detBean.displayName}
" value="${detBean.displayName}
">${detBean.displayName}
</input>

            </fieldset>
            <fieldset class="det">
                <legend>Materiel Data</legend>
                <input type="checkbox" name="${detBean.displayName}
" value="${detBean.displayName}
">${detBean.displayName}
</input>
            <br/>

        </fieldset>
      </td>
        </tr>

Thankx

1 个答案:

答案 0 :(得分:0)

这有效:

 <div id="displayFields" style="display:block;">
            <fieldset class="det">
                <legend>Header Data</legend>
                <c:forEach var="detBean" items="${detFields}">
                <c:if test="${detBean.groupName == 'HEADER_DATA'}">
                <input type="checkbox" name="${detBean.displayName}" value="${detBean.displayName}">${detBean.displayName}</input>
            <br/>
                </c:if>
                </c:forEach>
            </fieldset>
            <fieldset class="det">
                <legend>Materiel Data</legend>
                <c:forEach var="detBean" items="${detFields}">
                <c:if test="${detBean.groupName == 'MATERIEL_DATA'}">
                <input type="checkbox" name="${detBean.displayName}" value="${detBean.displayName}">${detBean.displayName}</input>
            <br/>
                </c:if>
                </c:forEach>
        </fieldset>