开发者

Invoke Javascript depending on a checkbox value

I am trying to figure out when to invoke a 开发者_StackOverflow中文版JavaScript when a checkbox is set to true. The thing is that the checkbox is given a dynamic name, since it's in table created from a database. So the name of the checkbox is dynamic created, with the name I gave it and a sequence number. The checkbox has a bean listener and when completed, invokes a JS, through ajax. I am using the standard JSF 2 datable in this case.

How can I determine if rowCheckbox is set to true before invoke JS (see the oncomplete ajax param)?

    ---
    <h:selectBooleanCheckbox id="rowCheckbox">
                                <a4j:ajax event="valueChange" listener="#dashboardController.tableRowIndexEvent}" execute="@form" oncomplete="addMarker('${item.geoposition.latDecDeg}', '${item.geoposition.longDecDeg}', '${item.geoposition.locationName}')"/>
        </h:selectBooleanCheckbox>
     ----

Regards Chris


This is how you can check if the checkbox is checked:

<input type="checkbox" id="cb1" onclick="if(this.checked) alert('Hurray'); else return False;"/>

See it in action here: http://jsfiddle.net/yKEWF/2/


I've not used JSF but perhaps the listener is scoped to the checkbox?

If so it would be "this.checked"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜