I have two string collection.
One is to generate all check boxes.
The other one is to select the element to check.
For example, I have two string collections ["A", "B", "C", "D"] ["A", "C"]
I want to make 4 check boxes A, B, C, D and want to check A and C
I tried as below.
<span th:each="interestName : ${allInterest}">
<span th:each="interest : ${userInfo.interestName}">
<input type="checkbox"
name="eachUserInterest"
th:value="${interestName.name}"
th:checked="${interestName.name.equals(interest)}"/>
<label th:text="${interestName.name}"></label>
</span>
</span>
However, above code generates a check box repeatedly as many times as it is checked. Execution Results
Help me, please.
Aucun commentaire:
Enregistrer un commentaire