Skip to main content
first.officer
Inspiring
December 22, 2020
Answered

Fields hidden if 2 radio buttons default is unchecked...

  • December 22, 2020
  • 5 replies
  • 1680 views

Hi all,

 

Have the script shown below. It works well in as much as when the relevant selections are made in the radio buttons (STEP), the var A,B,C all work as planned - but what I would like to do is that when the form is reset (i.e. radio button fields are unchecked), to have all fields hidden - which is where the last part is likely wrong in my script, but cannot get it to work - any ideas?;

 

var V = this.getField("STEP");

var A = this.getField("START_DEICE");

var B = this.getField("START_ANTIICE");

var C = this.getField("STOP_ANTIICE_DEICE");

if (V.value === "Choice1") {

A.hidden = false;

B.hidden = true;

C.hidden = false;

 

}

if (V.value === "Choice2") {

A.hidden = false;

B.hidden = false;

C.hidden = false;

 

}

if (V.value === "") {

A.hidden = true;

B.hidden = true;

C.hidden = true;

 

}

This topic has been closed for replies.
Correct answer JR Boulay

"Yes, that is one option"

It is not an "option", you have no choice. Acrobat's "reset" function only resets the fields to their default value, if you want to go further (hide some fields, …) you have to use JavaScript, via a dedicated button.

5 replies

JR Boulay
Community Expert
Community Expert
December 22, 2020

"So, is there a way to make the RESET trigger the script?"

Yes.

By using a (hidden) field whose value is different from its default value. A calculation script can easily detect whether or not the value of this field is different from its default value.

If the two values are equal, the document has been reset.

Acrobate du PDF, InDesigner et Photoshopographe
JR Boulay
Community Expert
Community Expert
December 22, 2020

"So, is there a way to make the RESET trigger the script?"

Not directly.

Hélas.

Acrobate du PDF, InDesigner et Photoshopographe
first.officer
Inspiring
December 22, 2020

Many thanks for the replies all, much appreciated - and as JR Boulay has posted (and is the answer), the problem is now resolved.

JR Boulay
Community Expert
JR BoulayCommunity ExpertCorrect answer
Community Expert
December 22, 2020

"Yes, that is one option"

It is not an "option", you have no choice. Acrobat's "reset" function only resets the fields to their default value, if you want to go further (hide some fields, …) you have to use JavaScript, via a dedicated button.

Acrobate du PDF, InDesigner et Photoshopographe
Nesa Nurani
Community Expert
Community Expert
December 22, 2020

Change: if (V.value === "") { to if (V.value === "Off") {

first.officer
Inspiring
December 22, 2020

Hi Nesa, I tried that previously, but sadly when the from is reset the fields still remain visible....

first.officer
Inspiring
December 22, 2020

When you reset the form it will not trigger your script.


"When you reset the form it will not trigger your script."

 

So, is there a way to make the RESET trigger the script?

JR Boulay
Community Expert
Community Expert
December 22, 2020

You should use a reset script:

 

this.resetForm();

this.getField("STEP").display = display.hidden;

this.getField("START_DEICE").display = display.hidden;

this.getField("START_ANTIICE").display = display.hidden;

// Etc.

Acrobate du PDF, InDesigner et Photoshopographe
first.officer
Inspiring
December 22, 2020

Hi JR,

 

Yes, that is one option - a good point 😉