Skip to main content
Known Participant
November 11, 2025
Question

JS to hide or show a group of fields

  • November 11, 2025
  • 10 replies
  • 300 views

(semi)newbie to javascript - go (somewhat) easy on me :O)

 

short version... working on a form where I need to either show a bunch of fields or hide them base on radio button choice.

 

Right now I have the fields visible (or hidden) based on the button's Action/Show/Hide Field. It works but there are +/-75 fields and it's cumbersome, at best.

 

Logically, I would like to group those +/-75 feilds but have no idea if this is available!?

 

Any help would be appreciated.   

10 replies

PDF Automation Station
Community Expert
Community Expert
November 11, 2025

Name the fields in the group with a hierarchical numbering scheme creating the first field, then right-click>Create multiple copies with 1 across and the rest down.  You will end up with fields named, for example, Text1.0 through Text1.74.  You can then create a calculation that loops through the fields and sets the visibility (display property).  Alternatively, you can put a custom calculation in the first field before using right-click > Create multiple copies that will show or hide depending on the value of the radio button choice:

if(this.getField("Radio 1").value == "A")

{event.target.display=display.hidden}

else

{event.target.display=display.visible}

 

If your fields don't have a numbering scheme and you don't want to individually enter a calculation script into every single field, this trick is for you:

https://pdfautomationstation.substack.com/p/secret-trick-for-changing-properties

HambergAuthor
Known Participant
November 11, 2025

Great info (for the next one :O/)!

Any easier way (short of renaming) if I have the 75+ fields (consisting of radio buttons, check boxes and text boxes) already named?