i want to add the disabled attribute on the form:hidden tag dynamically when i go over a list of objects in my model. the code i have (that doesn’t work) goes a little something like this:
<c:forEach items="${myModel.myList}" var="obj">
<div id="${obj.id}" onclick="selectObject(this);"><span>${obj.name}</span></div>
<form:hidden path="myModel.selectedObj" />
</c:forEach>
i want the hidden input of obj in the list that his id is equal to the selectedObj to not be disabled, and every other hidden input i want to be disabled. This is what i tried:
<form:hidden path="myModel.selectedObj" <c:out value="${obj.id != myModel.selectedObj.id ? "disabled=\"disabled\"" : ""}"></c:out> />
as i said, this didn’t work out. any thoughts?
Try with this piece of code:
Or you can use a
<c:choose />, with<c:when />and<c:otherwise />tags: