I want to set value differently and option differently in an Select tag
我想在Select标签中以不同方式设置值并选择不同的选项
ex.
<select name="myselect">
<option value="1">one</option>
</select>
that mean i have two list from DB
这意味着我有两个DB列表
1)one is Id of username to which i want to keep in value of select
2)second is username which is other. this i want to keep in between option tag
1)一个是我要保留的用户名的id,选择2)第二个用户名是另一个。这个我想保持在选项标签之间
Please Help
thanks Rakesh
1 个解决方案
#1
0
If you are sure that both of the list are in sync (in terms of index , i.e. user Abc from list a is at the top so id of the Abc in other list is at the top)
如果您确定两个列表都是同步的(就索引而言,即列表a中的用户Abc位于顶部,那么其他列表中的Abc的ID位于顶部)
You can do it following way
你可以按照以下方式做到
<c:forEach var="idOfPerson" items="${listOfId}" varStatus="status">
<option value="${idOfPerson}">${listOfNames[status.index]}</option>
</c:forEach>
#1
0
If you are sure that both of the list are in sync (in terms of index , i.e. user Abc from list a is at the top so id of the Abc in other list is at the top)
如果您确定两个列表都是同步的(就索引而言,即列表a中的用户Abc位于顶部,那么其他列表中的Abc的ID位于顶部)
You can do it following way
你可以按照以下方式做到
<c:forEach var="idOfPerson" items="${listOfId}" varStatus="status">
<option value="${idOfPerson}">${listOfNames[status.index]}</option>
</c:forEach>