I have an arrayList of values I'm using in my jsp file called "selectedMods". "selectedMods" contains the values of the previously checked checkboxes before form submission. I'd like for the checkboxes to remain checked when the form is refreshed. My line of thought here is that for each checkbox item, traverse the arraylist "selectedMods" of previously selected checkboxes and if that checkbox value equals any of the previously selected in "selectedMods" then check that checkbox. Here's the code for displaying the checkboxes:
<c:forEach items="${modules}" var="module">
<label class="checkbox"><input type="checkbox" name="moduleIds value="${module.id}" /> ${module.title}</label>
</c:forEach>
After "value" I thought about adding something like this:
<c:if test="${selectedMods == ${module.id}">checked="checked"</c:if>
But I realize I can't compare a list of values against a single value without traversing the list and I'm not sure where to start. Any help is much appreciated.
Aucun commentaire:
Enregistrer un commentaire