Hi
I am using Adobe LIvecycle designer ES2. I have about 20 checkboxs that need to show and hide the same fields. I can get it to show and hide the fields if the checkboxes are chosen. The problem lies when you unselect a check box as this will hide the fields however if the initial check box is not unchecked I want this information to stay there. How do I script to do this
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
You have complete control over this.
The following are various approaches if you had four checkboxes controlling the presence of a subform. All scripts are FormCalc and in the layout:ready event of the subform.
Where any checkbox would show the subform:
if (Sum(Checkbox1, Checkbox2, Checkbox3, Checkbox4) ge 1) then
$.presence = "visible"
else
$.presence = "hidden"
endif
Where all four checkbox have to be clicked to show the subform:
if (Sum(Checkbox1, Checkbox2, Checkbox3, Checkbox4) eq 4) then
$.presence = "visible"
else
$.presence = "hidden"
endif
Make sense?
Niall
Views
Replies
Total Likes
Hi,
Instead of having script in the click event (or what ever event) of each of the checkboxes, have a script in the fields that sums the 20 checkboxes and if this is greater than 0 (eg at least one checkbox is ticked) then show the field.
A kind of example here for suming radio buttons: http://assure.ly/uiKS6f. Another "related" example here: http://assure.ly/omsURE.
Hope that helps,
Niall
Views
Replies
Total Likes
Hi Niall
The problem is not all the fields show up all the time and sometimes it is a subform not just a field would this still work. Also each checkbox might show several fields at the same time.
michelle
Views
Replies
Total Likes
Hi Michelle,
I think you could get it to work. For example if a field's visibility depended on Checkbox1 and Checkbox2, then the script for this field would sum these two checkboxes. On the other hand if a different field depended on Checkbox 1, Checkbox5 and Checkbox8, then it would just sum these.
It would also work for subforms.
The easiest event to use is the layout:ready event, however this is not very effective as this event fires all the time the user interacts with the form. So depending on the complexity, you may need a different event.
Niall
Views
Replies
Total Likes
hi
another question I need them to be able to choose sometimes 1 checkbox and other times more will this work with the sum or will they have to choose all of the checkboxes listed in the sum.
Views
Replies
Total Likes
Hi,
You have complete control over this.
The following are various approaches if you had four checkboxes controlling the presence of a subform. All scripts are FormCalc and in the layout:ready event of the subform.
Where any checkbox would show the subform:
if (Sum(Checkbox1, Checkbox2, Checkbox3, Checkbox4) ge 1) then
$.presence = "visible"
else
$.presence = "hidden"
endif
Where all four checkbox have to be clicked to show the subform:
if (Sum(Checkbox1, Checkbox2, Checkbox3, Checkbox4) eq 4) then
$.presence = "visible"
else
$.presence = "hidden"
endif
Make sense?
Niall
Views
Replies
Total Likes
Hi Niall
This work well thanks. However I do have another problem now I think is to do with putting the script on the layout:ready. My fields and subforms that are set to flow don't flow. i.e when you remove the fields it just leaves the space and doesn't reset the form to close the space. Is there another function that I can use this on that won't upset my flow
thanks
michelle
Views
Replies
Total Likes
Hi,
I would have expected the layout to flow when using the layout:ready event.
Are you setting the presence to "hidden" and not "invisible"?
You may need to force a relayout, by including this at the end of the
script: xfa.layout.relayout();
A better approach would be to use a Script Object and place the script there
in a function. Then you could call the function in the click event of each
of the checkboxes. There are plenty of examples of script objects and
functions. This is much better than duplicating the script in the click
event of ALL of the checkboxes.
Hope that helps,
Niall
Views
Replies
Total Likes
Hi,
That did the trick I just added the force relayout at the end and this has fixed the problem
thanks
michelle
Views
Replies
Total Likes
Hi Niall
Further to the script above I have an additional requirement in some cases
How would I ????
Show the field based on the checkbox selection and raw value of a drop down field but also keeping in mind that you maybe able to select and unselect multiple checkboxes
michelle
Views
Replies
Total Likes
Hi,
You can achieve this with multiple conditions in the if/else statement. For example:
Where more than one chackbox has to be ticked AND the dropdown has a value "The required selection":
if (Sum(Checkbox1, Checkbox2, Checkbox3, Checkbox4) ge 1 and DropDown1 eq "The required selection") then
$.presence = "visible"
else
$.presence = "hidden"
endif
Alternatively, where more than one chackbox has to be ticked OR the dropdown has a value "The required selection":
if (Sum(Checkbox1, Checkbox2, Checkbox3, Checkbox4) ge 1 or DropDown1 eq "The required selection") then
$.presence = "visible"
else
$.presence = "hidden"
endif
You can also use nested if/else statements if the combinations of checkboxes/dropdowns is more complex.
Hope that helps,
Niall
Views
Replies
Total Likes
thanks Niall this works well and I did have to nest some if statements.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies