Skip to main content
Inspiring
April 12, 2024
Answered

I need to check that two form field names are visible before i make another form field visible.

  • April 12, 2024
  • 1 reply
  • 530 views

Hi there,

 

I need to get some javascript that will allow me to check that two form field names set to visible before setting the visiblility of the third. 

 

if(this.getField("Form Field Name").display == display.visible) && (this.getField("Form Field Name 2").display == display.visible) {

this.getField("Form field name 3").display = display.visible;

}

Any help will be greatly appreciated.

Steve

This topic has been closed for replies.
Correct answer Thom Parker

That code looks good, except that it is missing some parentheses. Did you check the console window? It would have reported a syntax error.

Under what circumstances do you want this to happen? 

 

Here's the correct code:

if((this.getField("Form Field Name").display == display.visible) && (this.getField("Form Field Name 2").display == display.visible)) {
     this.getField("Form field name 3").display = display.visible;
}

 

 

 

1 reply

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
April 12, 2024

That code looks good, except that it is missing some parentheses. Did you check the console window? It would have reported a syntax error.

Under what circumstances do you want this to happen? 

 

Here's the correct code:

if((this.getField("Form Field Name").display == display.visible) && (this.getField("Form Field Name 2").display == display.visible)) {
     this.getField("Form field name 3").display = display.visible;
}

 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Inspiring
April 12, 2024

Works perfectly, 

 

many thanks,