Highlighted

Need to add to a javascript but not sure how to

Participant ,
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, PDF forms

Views

261

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

Need to add to a javascript but not sure how to

Participant ,
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, PDF forms

Views

262

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

Copy link to clipboard

Copied

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

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
Reply
Loading...
Participant ,
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
Reply
Loading...
Adobe Community Professional ,
Jun 06, 2020

Copy link to clipboard

Copied

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. 

 

 

 

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
Reply
Loading...
Resources
One Stop Solution for Acrobat
Edit a PDF