Skip to main content
bb28222058
Participating Frequently
April 24, 2016
Answered

When a check box is checked, populate a text field with a value

  • April 24, 2016
  • 2 replies
  • 5697 views

I'm sure this is simple; however I am very new to acrobat and javascript.

Here is what I want to do:

I have a CheckBox field and a Text field. If the checkbox is "checked" I want to populate the text field with a specific numeric value.  If it is left "unchecked" there would be no value or 0 value.  Any help is appreciated.

This topic has been closed for replies.
Correct answer try67

Enter this code as the custom calculation script of your text field:

event.value = this.getField("CheckBox1").value == "Off" ? 0 : 1234;

2 replies

Known Participant
January 19, 2024

When I put in this script, it automatically puts my text field as '1234'. I need the text field to be editable by the user. For example, if check box 1 is checked, text field 1 needs a required population data of the users choice, i/e 1500, 1600, and so on.

Known Participant
January 19, 2024

@try67 When I put in this script, it automatically puts my text field as '1234'. I need the text field to be editable by the user. For example, if check box 1 is checked, text field 1 needs a required population data of the users choice, i/e 1500, 1600, and so on.

try67
Community Expert
Community Expert
January 19, 2024

So you want the check-box to only clear the text field, when No is selected?

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
April 24, 2016

Enter this code as the custom calculation script of your text field:

event.value = this.getField("CheckBox1").value == "Off" ? 0 : 1234;

bb28222058
Participating Frequently
April 24, 2016

Perfect.  Thank you.