我想在选择组合“#accountSelector”中使用 CODE !="abc012345" 将项目设为蓝色;
我尝试了以下解决方案,它可以正常工作,但是有代码复制(“ option ”标记的内容被复制到 IF ELSE 语句中)。
如何更改选项标签的颜色以避免代码复制?有没有 javascript/jquery 更清洁的解决方案?
<table border="0" cellPadding="0" cellSpacing="0" >
<logic:notEmpty name="enabledReportsList" >
<tr>
<td>
<select id="accountSelector" name="accountSelector" style="WIDTH: 380px" class="comboFilter" onChange="preSubmit();document.changeReports.submit()">
<logic:iterate id="cc" indexId="ccn" name="enabledReportsList" >
<% if (!( ((it.myproject.common.Report)cc).getCode() ).equals("abc012345")){%>
<option style="color:blue" value="<bean:write name="cc" property="Report"/>" <%= ( ((it.myproject.common.Report)cc).getReport() ).equals(session.getAttribute("accountSelector")) ? "selected" : "" %> >
<bean:write name="cc" property="fullValue"/>
</option>
<%} else {%>
<option value="<bean:write name="cc" property="Report"/>" <%= ( ((it.myproject.common.Report)cc).getReport() ).equals(session.getAttribute("accountSelector")) ? "selected" : "" %>>
<bean:write name="cc" property="fullValue"/>
</option>
<%}%>
</logic:iterate>
</select>
</td>
<td class="filterheader">
<b><bean:message key="selector.account" arg0="${fn:length(enabledReportsList)}"/></b>
</td>
</tr>
</logic:notEmpty>
<logic:empty name="enabledReportsList" >
<tr>
<td class="filterheader">
<bean:message key="ENABLED_REPORTS.combo.empty"/>
</td>
</tr>
</logic:empty>
</table>