Skip to main content
Known Participant
July 11, 2024
Answered

Adding code to display portion of page based on checkbox selected.

  • July 11, 2024
  • 2 replies
  • 786 views

I am attempting to create a document that displays sections based on a checkbox selection. Some of the content on the page was copied and pasted from Word and some created in Adobe. Would it all have to be created through Adobe in order to hide/show with selections?

This topic has been closed for replies.
Correct answer Thom Parker

Amazing!!!! It works! Thank you sooooo much!


keep in mind that all of the solutions dicussed here will only work when the form is displayed on a viewer that implemets scripting and the show/hide actions.  Which almost certainly does not include mobile devices and browsers. 

 

 

2 replies

PDF Automation Station
Community Expert
Community Expert
July 11, 2024

You could copy the content to an image file, then import it into a button field, then show/hide the button field with a script in the check box.  Or you could create a Read Only field with white fill and hide the content with it.  To show the content, hide the field and vice versa.

Nesa Nurani
Community Expert
Community Expert
July 11, 2024

You can use, text field, place it over the part of the page you wish to show/hide, then use the built-in show/hide action in checkbox to show/hide the text field or you can use a script, if you give your text field a name "Text1",

as 'Mouse UP' checkbox action:
this.getField("Text1").display = (event.target.value == "Off") ? display.visible : display.hidden;

Known Participant
July 11, 2024

Thank you! I have the Mouse Up set to 'hide' the text box on top of the part of the page to show with the corresponding checkbox. This works perfectly! However, can I get it to 'show' the text box again (blocking that portion) if that same check box is then unselected?

Nesa Nurani
Community Expert
Community Expert
July 11, 2024

Yes, instead of built in show/hide use the script I gave you.