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

Need to add to a javascript but not sure how to

Participant ,
May 28, 2020 May 28, 2020

Copy link to clipboard

Copied

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

jlehane_1-1590678002545.png

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

TOPICS
Acrobat SDK and JavaScript

Views

281

Likes

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 ,
May 29, 2020 May 29, 2020

Copy link to clipboard

Copied

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

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

Likes

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
Participant ,
Jun 05, 2020 Jun 05, 2020

Copy link to clipboard

Copied

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.

Likes

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 ,
Jun 06, 2020 Jun 06, 2020

Copy link to clipboard

Copied

LATEST

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 PDFScripting
Use the Acrobat JavaScript Reference early and often

Likes

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