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

Need to make form field names into an array in javscript.

Explorer ,
Apr 15, 2024 Apr 15, 2024

Copy link to clipboard

Copied

Hi there,

 

I have 15 form fields that i would like to be made into an array so they can be made visible in one go. 

 

So instead of me having to type out the javascript as the below:

 

{this.getField("Sect-3 EDN TF1").display = display.visible;
this.getField("Sect-3 EDN TF2").display = display.visible;
this.getField("Sect-3 EDN TF3").display = display.visible;
this.getField("Sect-3 EDN TF4").display = display.visible;
this.getField("Sect-3 EDN TF5").display = display.visible;
this.getField("Sect-3 EDN TF6").display = display.visible;
this.getField("Sect-3 EDN TF7").display = display.visible;
this.getField("Sect-3 EDN TF8").display = display.visible;
this.getField("Sect-3 EDN TF9").display = display.visible;
this.getField("Sect-3 EDN TF10").display = display.visible;
this.getField("Sect-3 EDN TF11").display = display.visible;
this.getField("Sect-3 EDN TF12").display = display.visible;
this.getField("Sect-3 EDN TF13").display = display.visible;
this.getField("Sect-3 EDN TF14").display = display.visible;
this.getField("Sect-3 EDN TF15").display = display.visible;}

 

I would like to be able to set a variable next to the textfield names. 

 

Many thanks in advance, 

 

Steve

TOPICS
JavaScript , Modern Acrobat

Views

105

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 , Apr 15, 2024 Apr 15, 2024

You don't even need to use an array. This code will work just as well:

 

for (var i=1; i<=15; i++) {
	this.getField("Sect-3 EDN TF"+i).display = display.visible;
}

Votes

Translate

Translate
Community Expert ,
Apr 15, 2024 Apr 15, 2024

Copy link to clipboard

Copied

You don't even need to use an array. This code will work just as well:

 

for (var i=1; i<=15; i++) {
	this.getField("Sect-3 EDN TF"+i).display = display.visible;
}

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
Explorer ,
Apr 15, 2024 Apr 15, 2024

Copy link to clipboard

Copied

LATEST

Perfect, many thanks

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