[英]How to assign a boolean value of an JSF selectBooleanCheckbox as parameter to a java script function?
I have the following example in my jsf xhtml page: 我在jsf xhtml页面中有以下示例:
<h:selectBooleanCheckbox value="#{bean.fieldvalue1}" onchange="updateJsFunction(this);"/>
The parameter "this" for the js function "updateJsFunction" doesn´t includes the value of the selectBooleanCheckbox, which was selected or deselected. js函数“updateJsFunction”的参数“this”不包括selectBooleanCheckbox的值,该值已被选中或取消选中。
Is there a way to assign the value of an selectBooleanCheckbox in a java script function? 有没有办法在java脚本函数中分配selectBooleanCheckbox的值?
Yes you have to work on the DOM. 是的,你必须在DOM上工作。 The 'this' you refer to is the generated HTML checkbox, you must see if it has the attribute 'checked'.
您引用的“this”是生成的HTML复选框,您必须查看它是否具有“已检查”属性。 If you use jQuery it would be something like:
如果你使用jQuery,它将是这样的:
jQuery(this).is(':checked')
You can replace onchange="updateJsFunction(this);"
你可以替换
onchange="updateJsFunction(this);"
with onchange="updateJsFunction(event);"
with
onchange="updateJsFunction(event);"
And then do what ever you want with $(event.target)
(if you use jQuery) or inspect the event.target
with js 然后使用
$(event.target)
(如果使用jQuery)或使用js检查event.target
,随意执行任何操作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.