如果设置了请求变量,我想在加载页面时设置组合框的选定文本(而不是值)。我的属性名是'modified',所以我尝试这样做:
javascript:function selection(sel, text) {
if(text != '' || text != null || typeof(text) != 'undefined' ) {
sel.options[sel.selectedIndex].innerHTML = text;
}
在我的HTML中:
<c:if test="${modified == 1}">
<DIV class="modified">Group : ${groupe} was modified.
<script>
selection(combobox, ${groupe});
</script>
</DIV>
</c:if>
<c:..>
标签来自spring-mvc,我的div打印出来很好
我不确定我可以访问我的EL到一些javascript。
我可以同时使用js和jquery。
结束点是检索选定的组合框文本,之后我提交了一个表单,以预选相同的组合框与最后的selectedText(不知道如果我足够清楚)
提前感谢:)
${groupe}
将只输出变量的内容,因此您最终将得到如下内容:
selection(combobox, content of your variable);
但是你需要:
selection(combobox, "content of your variable");
所以只需添加引号并使用<c:out>
:
selection(combobox, "<c:out value="${groupe}"/>");