Skip to main content
Participating Frequently
November 1, 2016
Answered

If/then script needed so a text field is automatically filled in if a specific checkbox is checked

  • November 1, 2016
  • 8 replies
  • 1072 views

I am making a simple fillable acrobat pdf form. I would like a text block to automatically be filled with a number (specifically, "$8.00") if and only if a neighboring check box is checked. I surely would appreciate any help. By the way, the name of the checkbox is MailingCheckbox and the name of the text field is MailingFee. Below is a screenshot of the specific area of the form. Thanks in advance!

This topic has been closed for replies.
Correct answer try67

OK. Use this code as the custom calculation script of the text field, then:

event.value = (this.getField("MailingCheckbox").valueAsString=="Off") ? 0 : 8;

8 replies

try67
Community Expert
Community Expert
November 2, 2016

If the box is not ticked, should the text box be enabled for user input, or should it be set as zero (or as blank) automatically?

Participating Frequently
November 2, 2016

Thank you, try67! Good question. I was thinking that if the checkbox was NOT checked, the text block would remain blank, but I guess it could be $ 0.00 to begin with and change to $ 8.00 if checked.

Sure appreciate your response!

Jim

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
November 2, 2016

OK. Use this code as the custom calculation script of the text field, then:

event.value = (this.getField("MailingCheckbox").valueAsString=="Off") ? 0 : 8;