Login  Register

How to make all the checkbox values checked on selecting one of the checkbox value?

classic Classic list List threaded Threaded
5 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

How to make all the checkbox values checked on selecting one of the checkbox value?

Arjun
25 posts
Hi ,


  I have a check-box control with say 3 three values.Now the requirement is i want to make all the check-boxes selected on selecting one of the value out of the three.I tried with xf:setvalue but failed in succeeding.Is there any other way we can achieve this functionality?


Regards,
Arjun
Jez
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: How to make all the checkbox values checked on selecting one of the checkbox value?

Jez
39 posts
Hi Arjun

I would use the calculate attribute on the bind for the control. So if control1 is your "select all" control, use calculate="if (data($control1)) then true() else ." for the binds of the other 2 controls.

Regards

Jez
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: How to make all the checkbox values checked on selecting one of the checkbox value?

Erik Bruchez
Administrator
6632 posts
In reply to this post by Arjun
Arjun,

The following works for me:

    https://gist.github.com/ebruchez/c93df1001258a62ec586

The action is as follows:

    <xf:setvalue
        ev:event="xforms-value-changed" observer="checkboxes-control"
        if="xxf:split(event('xxf:value')) = '1'"
        ref="event('xxf:binding')"
        value="'1 2 3'"/>

But I am not sure it does exactly what you want, in that if you select One, then Two and Three are selected, but then you can't deselect Two or Three (they come back if One remains selected).

-Erik
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: How to make all the checkbox values checked on selecting one of the checkbox value?

Arjun
25 posts
Hi Erik,

    I copied the code directly and checked in my local set-up ,But falied to make it work.When  I tried changing the 'xf:setvalue' ref attribute to the actual instance of the element i.e., instance('fr-form-instance')//<Control-name> then its working fine.whether I was missing something  or can I make ref attribute as instance('fr-form-instance')//Control-name


Regards,
Arjun
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: How to make all the checkbox values checked on selecting one of the checkbox value?

Erik Bruchez
Administrator
6632 posts
Is the `xxf` namespace prefix in scopein your form? Some older forms were using `xxforms`.

-Erik