我有一个jsp,想在下拉菜单中使用scriplet禁用下拉列表而不使用任何onclick方法或事件
<%
boolean something= true;
if(something){
// here I want to get plc1 using id and want to disable it if it is true
}else{
//do some thing
}
%>
我的下拉html代码在这里
<td bgcolor='' align="center" ><select id = "plc1" name="place1" onclick="this.parentNode.style.backgroundColor = this.value">
<option value='red'>Park here</option>
<option value='green'>Cancel</option>
</select></td>
怎么做?有什么提示吗?
答案 0 :(得分:1)
只需使用disabled
属性:<select id="plc1" disabled>
<%
String state = "";
if(something){
state = "disabled";
}
%>
<select id="plc1" <%= state %>>
答案 1 :(得分:-1)
<%
boolean something=false;
String state = "";
if(something){
state = "disabled";
// here I want to get plc1 using id and want to disable it if it is ture
}else{
state = "enable";
}
%>
HTML
<select <%= state %> id = "plc1" >
现在正在工作谢谢