Skip to main content
subieguy2
Inspiring
November 1, 2018
Question

Field handling

  • November 1, 2018
  • 1 reply
  • 1297 views

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!

This topic has been closed for replies.

1 reply

Bernd Alheit
Adobe Expert
November 1, 2018

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

subieguy2
subieguy2Author
Inspiring
November 1, 2018

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

Bernd Alheit
Adobe Expert
November 1, 2018

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

if (theFieldsPage == this.pageNum) {


Remove