Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to add c:if inside the <option> tag

843840Jun 17 2008 — edited Jun 17 2008
Hi,

I want to add a <c:if> tag inside the <option> tag. This is my code.
<select name="select" size="10" multiple="false" class="listboxes" id="select">
	<c:forEach items="${variableSet.variables}" var="tv" varStatus="loopStatus">
	<option value="${tv.variableId}" <c:if test="${loopStatus.index==1}">
                    <c:out value="selected"></c:if>>${tv.variableName}</option></c:forEach>						
</select>
what i want to do here is this is to keep the first value in the list selected
<option selected="selected">Age Group</option>
if this is wrong, can somebody tell me another way to keep the first value selected in my listbox. This list is a dynamic one.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 15 2008
Added on Jun 17 2008
1 comment
348 views