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

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

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

Arjun
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
|

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

Jez
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
|

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

Erik Bruchez
Administrator
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
|

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

Arjun
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
|

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

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

-Erik