简体   繁体   中英

How to load values in dropdown whose ID is not used…hide all records whose values are already used?

This shows all the records.Please help me to show only the records whose id is not used ..

<select name="userDetailId" class="form-control" required>
          <option value="">Select</option>

         <c:forEach items="${userDetailList}" var="userDetail">

         <option value="${userDetail.userDetailId}" <c:if test="${userDetail.userDetailId == dataMap.userDetailId}"> selected </c:if> >${userDetail.name}</option>

         </c:forEach>
     </select>

Create some flag let's say isUsed and populate it's value as either true/ false ie used or not and add similar condition as below.

<select name="userDetailId" class="form-control" required>
          <option value="">Select</option>

         <c:forEach items="${userDetailList}" var="userDetail">
<c:if test="${isUsed}"> 
         <option value="${userDetail.userDetailId}" <c:if test="${userDetail.userDetailId == dataMap.userDetailId}"> selected </c:if> >${userDetail.name}</option>
</c:if> 
         </c:forEach>
     </select>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM