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

Field handling

Engaged ,
Nov 01, 2018 Nov 01, 2018

Copy link to clipboard

Copied

I have the following code (which probably isn't written the most efficient)....

// TURN ON ALL EYE ICONS FOR THIS PAGE

if (this.getField("groundState") != null){

var getState = this.getField("groundState");

var theFieldsPage = getState.page;

if (getState != null) {

// Look through the fields page numbers

for (var z = 0; z < theFieldsPage.length; z++) {

// Find the field on the right page

if (theFieldsPage == this.pageNum) {

// Only change the display of the field on this page

getField("groundState." + z).display = display.hidden;

}}}

}

// TURN ON ALL EYE ICONS FOR THIS PAGE

if (this.getField("021state") != null){

var getState = this.getField("021state");

var theFieldsPage = getState.page;

if (getState != null) {

// Look through the fields page numbers

for (var z = 0; z < theFieldsPage.length; z++) {

// Find the field on the right page

if (theFieldsPage == this.pageNum) {

// Only change the display of the field on this page

getField("021state." + z).display = display.hidden;

}}}

}

// TURN ON ALL EYE ICONS FOR THIS PAGE

if (this.getField("032state") != null){

var getState = this.getField("032state");

var theFieldsPage = getState.page;

if (getState != null) {

// Look through the fields page numbers

for (var z = 0; z < theFieldsPage.length; z++) {

// Find the field on the right page

if (theFieldsPage == this.pageNum) {

// Only change the display of the field on this page

getField("032state." + z).display = display.hidden;

}}}

}

It is applied to a button. If the field groundState exist and 032state exists.... how do I get it to hide those fields?

So 021state doesn't exist in this particular document... I thought if I put it != null that would work. Currently it only hides the field groundState and doesn't hide the 032state field as it should.

Any suggestions would be most appreciated! Feel free to make suggestions for optimizing the script as well

Thanks in advance!

TOPICS
Acrobat SDK and JavaScript

Views

858

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 ,
Nov 01, 2018 Nov 01, 2018

Copy link to clipboard

Copied

How many fields with the name "032state" are in the document?

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
Engaged ,
Nov 01, 2018 Nov 01, 2018

Copy link to clipboard

Copied

It varies. Could be 0.... could be up to 8.

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 ,
Nov 01, 2018 Nov 01, 2018

Copy link to clipboard

Copied

When there are only one field with the name the property page will not return a array.

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
Engaged ,
Nov 01, 2018 Nov 01, 2018

Copy link to clipboard

Copied

OH I see! Any suggestions for how to address that?

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 ,
Nov 01, 2018 Nov 01, 2018

Copy link to clipboard

Copied

Compare the property page with the current page.

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
Engaged ,
Nov 01, 2018 Nov 01, 2018

Copy link to clipboard

Copied

I thought that is what I was doing with this line?...

if (theFieldsPage == this.pageNum) {

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 ,
Nov 01, 2018 Nov 01, 2018

Copy link to clipboard

Copied

Remove

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
Engaged ,
Nov 01, 2018 Nov 01, 2018

Copy link to clipboard

Copied

Ok so when I do that it doesn't function properly.... here is what my updated script looks like:

// TURN ON ALL EYE ICONS FOR THIS PAGE

if (this.getField("groundState") != null){

var getState = this.getField("groundState");

var theFieldsPage = getState.page;

// Find the field on the right page

if (theFieldsPage == this.pageNum) {

// Only change the display of the field on this page

getField("groundState").display = display.visible;

}}

// TURN ON ALL EYE ICONS FOR THIS PAGE

if (this.getField("021state") != null){

var getState = this.getField("021state");

var theFieldsPage = getState.page;

// Find the field on the right page

if (theFieldsPage == this.pageNum) {

// Only change the display of the field on this page

getField("021state").display = display.visible;

}}

// TURN ON ALL EYE ICONS FOR THIS PAGE

if (this.getField("032state") != null){

var getState = this.getField("032state");

var theFieldsPage = getState.page;

// Find the field on the right page

if (theFieldsPage == this.pageNum) {

// Only change the display of the field on this page

getField("032state").display = display.visible;

}}

It doesn't turn on the fields because if there are multiple instances they are  032state#0 032state#1

So it doesn't turn any of them on. That is why I had the script originally written with this in it:

// Look through the fields page numbers

for (var z = 0; z < theFieldsPage.length; z++) {

// Find the field on the right page

if (theFieldsPage == this.pageNum) {

// Only change the display of the field on this page

getField("032state." + z).display = display.visible;

}}

Thank you for sticking with me on this! I appreciate it!

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 ,
Nov 01, 2018 Nov 01, 2018

Copy link to clipboard

Copied

LATEST

Don't delete the z loop.

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