I've a JSP page that load some info from a DAO to a select element. Something like this:
<select id="dropdown" onchange="changeKa()">
<c:forEach var="ka" items="${KaList}">
<option value="<c:out value='${ka.area}' />"
<c:if test="${param.selectValue == ka.area})"> selected </c:if> >
<c:out value="${ka.area}" />
</option>
</c:forEach>
</select>
Where I have
<option value="<c:out value='${ka.area}' />" ...
I want to set an id like this:
<option value="<c:out value='${ka.area}' />" id="<c:out value='${ka.id_knowledgearea}' />" ...
But the following error appears:
Bad value " " for attribute "id" on element "option": An ID must not contain whitespace.
How can I solve this?
Workaround...
So far I managed to overcome the problem by assigning the variable id_knowledgearea the label attribute of option. Like this:
Anyway, I'd like to understand how to assign the variable "id_knowledgearea" to the id of the element "option"...
Try this:
Try to delete all useless spaces as follows: