Kaz*_*ara 5 javascript jsp button
如何通过检查jsp中的条件来禁用按钮?如果为true,则启用该按钮,如果为false,则禁用该按钮.条件是检查变量的值.我知道如何使用javascript禁用按钮,但是将它与jsp中的条件一起使用是我无法弄清楚的.它可能吗?
尝试使用这样的JSTL结构:
<input type="button" <c:if test="${variable == false}"><c:out value="disabled='disabled'"/></c:if>">
Run Code Online (Sandbox Code Playgroud)
更多的例子见http://www.ibm.com/developerworks/java/library/j-jstl0211/index.html
或者干脆你可以el像这样直接使用它:
<input type="button" ${ condition ? 'disabled="disabled"' : ''}/>
Run Code Online (Sandbox Code Playgroud)
举个例子:
<input type="button" ${ someVariable eq 5 ? 'disabled="disabled"' : ''}/>
Run Code Online (Sandbox Code Playgroud)