[英]Change JSP custome attribute value using javascript for JSP custome tag
我已经开发了一个名为<ctn:input mandatory = true>
JSP自定义标记,它带有一个名为强制的自定义属性。 现在,我想将某些其他标签的click事件上的强制性值更改为false
。
我无法使用document.getElementById(id).mandatory = "false".
进行更改document.getElementById(id).mandatory = "false".
可能吗 ? 怎么样 ?
<ctn:input mandatory = true>
是服务器端的内容,客户端不会将此作为HTML dom接收,因此您的Java脚本将无法使用它。 您需要找到其他相同的方法
在这种情况下,您不能使用javascript来更改值...但是可以使用
<c:if > </c:if>
在ur属性值中。 对于前。
<ctn:input mandatory = "<c:if test='{yourCondition}'>true </c:if>">
或者我们也可以在这里使用select ... EX。 如果满足您的条件,它将选择true,否则将设置为false
<ctn:input mandatory = "<c:choose><c:when test="${condition/variable}">true </c:when><c:otherwise>false</c:otherwise>">
使用javascript,您只能修改呈现的html中的值。 它不会影响您的后端编码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.