Copy link to clipboard
Copied
I'm creating a PDF template using Adobe Acrobat, in which I'm trying to hide and show fields on button click.
My requirement is - on first click a field should be shown and on second click a same field should get hide.
My issue is - field is getting visible on first click but it doens't get hide on second click.
Can anyone please help me out with this.
Thanks in advance.
 
      Copy link to clipboard
Copied
Moving to the Acrobat forum from Community Help
Copy link to clipboard
Copied
You need to use a script to do it. Something like this:
var f = this.getField("FieldName");
f.display = (f.display==display.visible) ? display.hidden : display.visible;
Copy link to clipboard
Copied
Edit: Fixed small mistake in the code above.
Copy link to clipboard
Copied
This one works for me but only in one field. I need to hide/show several fields with one button. How shoud I modifiy the code?
Thank you
Copy link to clipboard
Copied
Duplicate the code, adjusting the field name in the first line each time.
Copy link to clipboard
Copied
Great. It worked. Now, is there a way to put all the names together in one line, having the fields the same name but ending in a different number?
Something like ("Field1", "Field2", "Field3", Etc.)
Copy link to clipboard
Copied
Sure:
var fieldNames = ["Field1", "Field2", "Field3"];
for (var i in fieldNames) {
var f = this.getField(fieldNames[i]);
f.display = (f.display==display.visible) ? display.hidden : display.visible;
}
Copy link to clipboard
Copied
Great. Worked like a charm. Much needed for a project. I really appreciate it. Thanks a thousand.
Copy link to clipboard
Copied
Great. Worked like a charm. Much needed for a school project. I really appreciate it. Thanks a thousand.
 
					
				
				
			
		
 
					
				
				
			
		
Find more inspiration, events, and resources on the new Adobe Community
Explore Now