如何设置默认值Combobox jsp [英] How to set default value Combobox jsp

查看:304
本文介绍了如何设置默认值Combobox jsp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置默认 value = $ {theObject2.countryId}

<select id="locationCountry" style="padding-left: 2em" >
<option value="">Country</option>
<c:forEach  items="${countrieDetail}" var="theObject" varStatus="theCount">
<option value="${theObject.countryId}" >${theObject.countryName}</option>
</c:forEach>
</select>


推荐答案

您可以使用 HTML selected属性

示例代码:

<select id="locationCountry" style="padding-left: 2em">
    <option value="">Country</option>
    <c:forEach items="${countrieDetail}" var="theObject">
        <option value="${theObject.countryId}" <c:if test="${theObject.countryId == theObject2.countryId }">selected</c:if>>
              ${theObject.countryName}
        </option>
    </c:forEach>
</select>

这篇关于如何设置默认值Combobox jsp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆