Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Move a field up depending on if checkbox is checked

Avatar

Level 1

Hello, say I have the following checkboxes:

A

B

C

D

With only the checkboxes that are ticked showing up on printed copy. Say only C & D are checked, as I have it now there is a lot of space between the previous field and C & D with A & B not printing. Is there a way to move these boxes up to the top to decrease the blank space?

Thanks.

1 Accepted Solution

Avatar

Correct answer by
Level 2

Ah! Yes, that's probably it. You'll need to mark those fields as "hidden" in the prePrint event as well.

View solution in original post

11 Replies

Avatar

Level 10

Hi,

What code are you using to print the checked checkboxes? and in what event?  You can set the presence property of the checkbox to hidden which will remove it from the layout of the form, or set it to hidden which will not display the checkbox but will still take up space on the form.

Regards

Bruce

Avatar

Level 2

First, you need to have the fields within a sub-form where the Content is set to "Flowed" rather than "Positioned". That way, when a field is "hidden", the other fields will move up to fill the space.

Next, for each of the checkboxes, you should add some JavaScript code to the prePrint event that make the field hidden if it is checked, something like this:

if (this.rawValue == 1) {

  this.presence = "hidden";

}

Lastly, for each of the fields you will need some JavaScript in the postPrint event to display it again after the document is printed, like this:

this.presence = "visible";

Avatar

Level 1

Thanks but no luck yet. Wrapped each box in a flowed subform and no dice.

I have checkboxes arranged and when one is checked, a field right below it is set to appear but stays hidden if not checked. This is my scrip for pre-print:

if(CheckBox22.rawValue == false)

  {

    CheckBox22.relevant = "-print";

  }

It is a list of 11 checkboxes, just thought it would be nice for instance to have checkbox #8 move up to the top if #1-7 are not checked.

Thanks.

Avatar

Level 2

You said you "Wrapped each box in a flowed subform". Just to make sure there's no confusion here, all of the checkboxes are together in ONE flowed subform, not each checkbox alone in their OWN subform, right? Just checking.

Using .relevant = "-print" prevents the object from being printed, but does NOT cause it to stop using up space in the layout. .presence = "hidden" does the latter, so try using that. You'll then need to have .presence = "visible" in the corresponding script for the postPrint event, so that it will show up on the screen again after the document has been printed.

In the prePrint event:

if (CheckBox22.rawValue == false) {

    CheckBox22.presence = "hidden";

}

In the postPrint event:

CheckBox22.presence = "visible";

Actually, if you have this code on the events for CheckBox22 itself, you can just use "this", so the code would be:

In the prePrint event for CheckBox22:

if (this.rawValue == false) {

    this.presence = "hidden";

}

And in the postPrint event for CheckBox22:

this.presence = "visible";

Avatar

Level 1

Thanks but still nothing. Space remains. All checkboxes are wrapped in flowed subform, tried both pre-print and post-print scripts.

Avatar

Level 2

Are you saving it as an "Adobe Dynamic XML Form"? If you're saving it as a static PDF, it won't work.

Try testing it out on a new form (just a few checkboxes in a flowed subform) and confirm that you can get it to work there, then see whether you can get it to work in your real form.

Avatar

Level 1

It worked on a new form, but no fields were between the checkboxes- I think that is the problem. I have hidden fields between the checkboxes that only appear if the previous checkbox is checked.

Avatar

Correct answer by
Level 2

Ah! Yes, that's probably it. You'll need to mark those fields as "hidden" in the prePrint event as well.

Avatar

Level 1

Got it. Thanks a million Wally. I appreciate it.

Avatar

Level 2

Great! Glad to hear it's working!