• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

New Here ,
Jun 24, 2021 Jun 24, 2021

Copy link to clipboard

Copied

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

 

Views

279

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 25, 2021 Jun 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;
}

Votes

Translate

Translate
Community Expert ,
Jun 24, 2021 Jun 24, 2021

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 24, 2021 Jun 24, 2021

Copy link to clipboard

Copied

[Moderator moved to Coding Corner.]

 

Nancy O'Shea— Product User, Community Expert & Moderator

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 24, 2021 Jun 24, 2021

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 25, 2021 Jun 25, 2021

Copy link to clipboard

Copied

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;
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 02, 2021 Jul 02, 2021

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines