Checkboxes and input visibility

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

Checkboxes and input visibility

akail
Hi,

Can You suggest me how to make a visibility rule with checkboxes and input.

Source:
https://gist.github.com/anonymous/8974440

I have checkboxes with three choices.

I want if selected first choice then display first input, if selected second choice then display second input. But if selected first and second choice then display first input, and when first input would be fill, than display second input.
If selected all, than input display one by one if its are filled.



I was trying to write  a rule of visibility (you can see in source), but not work in all situation.


Reply | Threaded
Open this post in threaded view
|

Re: Checkboxes and input visibility

Alessandro  Vernet
Administrator
Hi,

Assuming you name the control with the checkboxes "choices", and the first input "input1", then the visibility rule for the:

- 1st input should be: xxf:split($choices) = ('one', 'two')
- 2nd input should be: xxf:split($choices) = 'two' or (xxf:split($choices) = 'one' and $input1 != '')

This is similar to what you're doing in your code, and the discrepancy between the above expression and what you have might come from me misunderstanding your description or it not being inline with what you want. (In particular, the behavior you describe for "If selected all..." looks the one you have for "if selected first and second choice...".)

But beyond the details, I hope you get the idea, and can adapt this to what you need precisely.

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Checkboxes and input visibility

akail
For me doesn't work.

I tried write visibility logic

if (xxf:split($control-1)=("one", "two") and $control-2!="" ) then true() else
(if (xxf:split($control-1)=("one", "two", "three") and $control-2!="") then true() else
(if (xxf:split($control-1)=("two", "three")) then true() else false() ))

But it not work properly.

xxf:split($control-1)=("one", "two") -> What it means?
1) "one" and "two"
2) "one" or "two"?


My idea is that: the user selected checkboxes, it appears only one input field, one by one. The other input fields appear, if he responds to a given field.

For example:

We have three choices:
1) first
2) second
3) third

And if he selected "first" and "third", then appears only first input field, when it be responds, then appears third input field and so on.


For me not work (xxf:split($control-1)="one" and xxf:split($control-1)!="two"), how to write, the chekcboxes choices not be selected?
Reply | Threaded
Open this post in threaded view
|

Re: Checkboxes and input visibility

akail
Hi,

I do what I want in very simply way. Here my source:

https://gist.github.com/anonymous/9066837

I think that this way is stupid because I have 8 choices, so in this example I should describe all cases.


Maybe You can suggest me better way how to do that?
Reply | Threaded
Open this post in threaded view
|

Re: Checkboxes and input visibility

Erik Bruchez
Administrator
Luckily it's much easier than that:

For $control-3:

xxf:split($control-1) = "two"
and $control-2 != ''

For $control-4:

xxf:split($control-1) = "three"
and $control-2 != ''
and $control-3 != ''

Now as you go to your 8 controls, that does add a bit of pain in the end! The last one would look like:

xxf:split($control-1) = "eight"
and $control-2 != ''
and $control-3 != ''
and $control-4 != ''
and $control-5 != ''
and $control-6 != ''
and $control-7 != ''

You could write it also:

xxf:split($control-1) = "eight"
and not(($control-2, $control-3, $control-4, $control-5, $control-6, $control-7) = '')

I hope this helps,

-Erik