Skip to main content
Participant
January 10, 2024
Answered

Hide/showing a text field depending on conditions

  • January 10, 2024
  • 1 reply
  • 1861 views

Hi,

My question is in two parts. I need to show the field ''eligible_Reguliere'' only if the value of the field ''Total'' is equal or bigger than 45. I tried to run scripts on the field ''eligible_Reguliere''. It doesn't work. I tried putting it in the main Javascript of the document. Doesn't work. My script is:

 

var totalField = this.getField("Total");

var eligibleField = this.getField("eligible_Reguliere");

if (totalField.value >= 45) { eligibleField.display = display.visible; }

else { eligibleField.display = display.hidden; }

 

My second part is that I have the field ''eligible_Rapide'' that must show if the box named ''10+'' is checked. How can I do it? 

Every research I do bring me back to this page: Définition des conditions d’affichage et de masquage des champs de formulaires (adobe.com)

But I NEVER those options in Acrobat. Help please!

This topic has been closed for replies.
Correct answer Nesa Nurani

For first question, use this script in "Total" field under 'Validate' tab:

var eligibleField = this.getField("eligible_Reguliere");
eligibleField.display = (Number(event.value) >= 45) ? 0:1;

For second question, use this script in ''eligible_Rapide'' field under 'Calculate' tab as 'Custom calculation script':

var box = this.getField("10+").valueAsString;
event.target.display = box === "Off" ? 1:0;

 

1 reply

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
January 10, 2024

For first question, use this script in "Total" field under 'Validate' tab:

var eligibleField = this.getField("eligible_Reguliere");
eligibleField.display = (Number(event.value) >= 45) ? 0:1;

For second question, use this script in ''eligible_Rapide'' field under 'Calculate' tab as 'Custom calculation script':

var box = this.getField("10+").valueAsString;
event.target.display = box === "Off" ? 1:0;

 

Participant
January 10, 2024

Awesome, thanks! It almost 100% works

I still have an issue here because My total value is calculated with the sum of values ''DVL 838'' ''DVL 839'' ''DVL 840'' Diplome 1e cycle'' ''Diplome 2e cycle'' ''Year 1 Waterloo'' ''Year 2 Waterloo'' ''value_Formation 1'' ''value_Formation 2'' ''value_Formation 3'' ''value_Congres 1'' ''value_Congres 2'' and ''value_Congres 3'' so I can't put a personnalised script here and do my sum

Nesa Nurani
Community Expert
Community Expert
January 10, 2024

For 'Total' field use it under 'Validate' tab not 'Calculate'.