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

Hide and show fields on button click in adobe acrobat

New Here ,
Dec 26, 2019 Dec 26, 2019

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.

4.9K
Translate
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
Guest
Dec 27, 2019 Dec 27, 2019

Moving to the Acrobat forum from Community Help

Translate
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 ,
Dec 27, 2019 Dec 27, 2019

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;

Translate
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 ,
Dec 27, 2019 Dec 27, 2019

Edit: Fixed small mistake in the code above.

Translate
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 ,
Feb 24, 2020 Feb 24, 2020

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

Translate
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 ,
Feb 24, 2020 Feb 24, 2020

Duplicate the code, adjusting the field name in the first line each time.

Translate
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 ,
Feb 24, 2020 Feb 24, 2020

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.)

Translate
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 ,
Feb 24, 2020 Feb 24, 2020

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

Translate
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 ,
Feb 24, 2020 Feb 24, 2020

Great. Worked like a charm. Much needed for a project. I really appreciate it. Thanks a thousand.

Translate
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 ,
Feb 24, 2020 Feb 24, 2020
LATEST

Great. Worked like a charm. Much needed for a school project. I really appreciate it. Thanks a thousand.

Translate
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