Skip to main content
Known Participant
May 28, 2020
Question

Need to add to a javascript but not sure how to

  • May 28, 2020
  • 1 reply
  • 1006 views

At the start, the fields on the below screenshot are all hidden apart from the Term box.

The script below sits in the custom validation field of the term box and adds ticks and makes visible certain fields if a term of under 2 is entered. It does differenet tick boxes etc if a term of 2 or over is entered. There is also a mouse up action that ticks all boxes if C is ticked. This all works perfectly.....

What I would like to do, but for the life of me cannot work out what I need to add, is for all the fields (except the term box) to reset to hidden if the term box is either blank or someone types 0.

 

if ( !this.getField("checkbox_c").isBoxChecked(0)) {
if ( event.value < 2) {
this.getField("checkbox_a").checkThisBox(0, false);
this.getField("checkbox_b").checkThisBox(0, true);
this.getField("checkbox_c").checkThisBox(0, false);
this.getField("checkbox_a").display = display.hidden;
this.getField("checkbox_c").display = display.hidden;
this.getField("SubsPerMth").display = display.hidden;
this.getField("checkbox_b").display = display.visible;
this.getField("ProfServices").display = display.visible;
this.getField("ProfservicesTotal").display = display.visible;
} else {
this.getField("checkbox_a").checkThisBox(0, true);
this.getField("checkbox_b").checkThisBox(0, false);
this.getField("checkbox_c").checkThisBox(0, false);
this.getField("checkbox_a").display = display.visible;
this.getField("checkbox_c").display = display.visible;
this.getField("SubsPerMth").display = display.visible;
this.getField("checkbox_b").display = display.hidden;
this.getField("ProfServices").display = display.hidden;
this.getField("ProfservicesTotal").display = display.hidden;
}
}

This topic has been closed for replies.

1 reply

Thom Parker
Community Expert
Community Expert
May 29, 2020

Use the validation script on the "term" box to set the visibility to hidden.

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
jlehaneAuthor
Known Participant
June 5, 2020

The term box always has to be visible - it's the other fields shown that I want to reset to hidden if the term box is blank or if a zero was entered.

Thom Parker
Community Expert
Community Expert
June 6, 2020

Use the Validation script on the term box to set the visibility of the other fields.

 

This script location is the best option because the visibility of the other fields depends on the value in the term box. And the validation script is only called when the value of the term box changes. 

 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often