Skip to main content
Rabin J
Known Participant
June 24, 2021
Answered

How to show/hide form fields list with a specific string in the field name

  • June 24, 2021
  • 4 replies
  • 368 views

How can I find & show/hide form fields with a specific strings start with "List1_", "List2_" in the field name and make them hidden until triggered.

 

I need the regular expression format to find the form fields name start with "List1".

 
Example

 

this.getField("List1_Oldfactory").display = display.hidden;
this.getField("List1_Optical").display = display.hidden;
this.getField("List1_Glosso").display = display.hidden;
this.getField("List1_Trigeminal").display = display.hidden;

 

Need to convert something like,

 

this.getField("List1_"+(/\s/g)).display = display.hidden;

 

but got error in condole as,

 

TypeError: this.getField(...) is null 1:Field:Mouse Up

 

    This topic has been closed for replies.
    Correct answer try67

    You can do it like this:

     

    for (var i=0; i<this.numFields; i++) {
    	var f = this.getField(this.getNthFieldName(i));
    	if (f==null) continue;
    	if (/^List1/.test(f.name)) f.display = display.hidden;
    }

    4 replies

    try67
    Community Expert
    try67Community ExpertCorrect answer
    Community Expert
    June 25, 2021

    You can do it like this:

     

    for (var i=0; i<this.numFields; i++) {
    	var f = this.getField(this.getNthFieldName(i));
    	if (f==null) continue;
    	if (/^List1/.test(f.name)) f.display = display.hidden;
    }
    Rabin J
    Rabin JAuthor
    Known Participant
    July 2, 2021

    Thanks for the script... It helps a lot!

    Rabin J
    Rabin JAuthor
    Known Participant
    June 25, 2021

    I am adding this script into Acrobat PDF, if possible please move to Acrobat.

    Nancy OShea
    Community Expert
    Community Expert
    June 24, 2021

    [Moderator moved to Coding Corner.]

     

    Nancy O'Shea— Product User & Community Expert
    John T Smith
    Community Expert
    Community Expert
    June 24, 2021

    Please post the exact name of the Adobe program you use so a Moderator may move this message to that forum